Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating google analytics using curl?

I need to execute a google analytics script on a site using curl. What are the reporting features that will be available to me for that curl request ?

To make my question more clearer, suppose i have a website www.abc.com which has analytics code on it and if i connect to www.abc.com from www.xyz.com using curl, in the analytics report of www.abc.com will the request i made using curl show ?

What are the parameters that wont show ? since there is no navigator there wouldnt be screen resolutions, color depth, or any other javascript based features. any other reporting features that wouldn't be available to me ?

I need the following to show up :

  • user agent (which i will be sending by setting header)
  • referrer (again which i will be sending by setting header)
  • source ip address and location (using proxies for different countries)

one issue that Im unsure of is Google's cookies and whether (since i might also be using proxies) these need to be cleared. The ultimate outcome is that I need to be able emulate site traffic as if it is coming from a variety of visitors....

IF the entire thing is not technically possible,is there any other way i can simulate diverse traffic into my google analytics account ?

like image 697
YD8877 Avatar asked Dec 09 '10 09:12

YD8877


3 Answers

So, the other answers are right: CURL doesn't execute JS, and there are some methods of automated requests that do.

Other methods to simulate diverse traffic to your account include:

  • Visit the site manually, and grab the __utm.gif request that Google Analytics generates, and manipulate its pieces so that you can CURL it in conjunction with curling the actual site, so that the GA pageviews are recorded. (ie, alter the hostname, pageview name, timestamp, etc.) You can find the meaning of the values of those parameters here.
  • Implement a server side GA on your target site.
  • Use a headless web engine to programmatically crawl sites. PhantomJS is a particularly user-friendly option.
  • Use a browser screenshot service like BrowserShots to get traffic from distributed locations to visit your site.
  • Use Amazon's Mechanical Turk to get people to visit the site. You could pay $0.01 per click, and get a large amount of diverse traffic from a large number of sources. (To verify, give them an arbitrary, simple task like asking them "What's the headline on this website?")
like image 182
Yahel Avatar answered Oct 02 '22 13:10

Yahel


You can send events directly to Google Analytics using the Measurement Protocol, creating GET or POST requests directly with the tool of your choice.

See reference here: https://developers.google.com/analytics/devguides/collection/protocol/v1/reference

like image 29
Andrew Mackenzie Avatar answered Oct 02 '22 13:10

Andrew Mackenzie


No, because Google Analytics is based on Javascript and curl doesn't process HTML or Javascript.

like image 28
Henrik P. Hessel Avatar answered Oct 02 '22 13:10

Henrik P. Hessel