Milan Gajjar Milan Gajjar - 14 days ago 9
PHP Question

How to get Google analytics data in chart

I want to get

Google Analytics
data in any chart using
PHP


I have Created a project in my account and I have


tracking code

all credentials of google Auth.


I have follow this link
my tracking code is here

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-xxxxxxxx-1', 'auto');
ga('send', 'pageview');

</script>


but I don't know what to do further

Answer

trying to this one first download the .12 in your Authentication add sdndsuidds-fkmfsdfdsf-545.p12 file check this code in your file

$google_account = array(
  'email'   => 'your-project-email@developer.gserviceaccount.com',
  'key'     => file_get_contents('file-name.p12'),
  'profile' => 'profil-id'
);