Isset1988 Posted July 14, 2012 Share Posted July 14, 2012 Hello my friends Can anyone help me retrieve Unique Visitors and PageViews from Google Analytics? I try the code below but something goes wrong. http://davidwalsh.name/php-google-analytics Thank u! Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/ Share on other sites More sharing options...
trq Posted July 14, 2012 Share Posted July 14, 2012 Can you provide a better description of your problem than "something goes wrong" ? Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361467 Share on other sites More sharing options...
Isset1988 Posted July 14, 2012 Author Share Posted July 14, 2012 First of all thank you for your answer. I download this code. http://www.swis.nl/ga/ After that, i use the code bellow retrieve the data. //session_start for caching, if desired session_start(); //get the class require 'ga/analytics.class.php'; //sign in and grab profile $analytics = new analytics('david@davidwalsh.name', 'myP@ssw0rd'); $analytics->setProfileByName('davidwalsh.name'); //set the date range for which I want stats for (could also be $analytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD')) $analytics->setMonth(date('n'), date('Y')); //get array of visitors by day print_r($analytics->getVisitors()); //get array of pageviews by day print_r($analytics->getPageviews()); In the field $analytics i set my email: test@gmail.com and my password: ''Password" In the $analytics->setProfileByName(''); i put the UA-21075529-4 of my page. What i make wrong? Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361471 Share on other sites More sharing options...
trq Posted July 14, 2012 Share Posted July 14, 2012 How should we know? You haven't described any actual issue. Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361472 Share on other sites More sharing options...
Isset1988 Posted July 14, 2012 Author Share Posted July 14, 2012 It shows me an error page. Nothing further. I suppose that someone has an analytics account and should be test it. --- How can you count unique visitors on your web sites? Thank u again! Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361474 Share on other sites More sharing options...
trq Posted July 14, 2012 Share Posted July 14, 2012 It shows me an error page. Nothing further. I don't suppose it crossed your mind to provide that error message to the people you are asking to help you? I suppose that someone has an analytics account and should be test it. Sorry, that sentence makes no sense. How can you count unique visitors on your web sites? I'm not sure I could be bothered explaining that to you. Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361476 Share on other sites More sharing options...
Isset1988 Posted July 14, 2012 Author Share Posted July 14, 2012 The error is HTTP 500 (Internal Server Error). I think that i have something wrong on my login details. I'm not sure I could be bothered explaining that to you. I'm sorry. My english is not good. I make this thread to find an answer. I didnt force anyone help me. :-\ I believe that someone who tried this code, can help me. Thank u Quote Link to comment https://forums.phpfreaks.com/topic/265658-retrieve-google-analytics-visits-and-pageviews-with-php/#findComment-1361477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.