0
votes

I am using PhantomJS and the rasterize.js example to capture a screenshot of my website. The process is automated and a new screenshot is taken every five minutes to check the status of the website. I am using Google Analytics to track users on my website and would like to exclude the traffic generated by PhantomJS. To do this I am setting a _setVar cookie in the rasterize.js file and creating a custom filter in Google Analytics to filter out the traffic. For some reason this isn't working and I can't figure out why. I use the following code in rasterize.js to set the cookie:

phantom.addCookie({
  'name': '_setVar',
  'value': 'ignore_analytics',
  'domain': 'MyWebsite.io'
});

This method should work, but when I look at the real time traffic on my website in Google Analytics, the PhantomJS clients still show up. Why isn't this working?

1
Why would setting a cookie work ? GA does not send automatically cookie data to the tracking server, even if it's named after a (deprecated) GA method. - Eike Pierstorff
I read a tutorial (seerinteractive.com/blog/…) that suggested this as a method to exclude internal traffic. Please explain to me why this is incorrect. - ScottOBot
You can filter with a custom var in Google Analytics, but setting a cookie called setVar will not create a custom variable - the tutorial is a bit misleading (plus It's somewhat out of date, with Univeral Analytics the syntax changed). It would probably easier to filter by browser name (Filters->Advanced->Exclude->Filter Field "Browser name"). - Eike Pierstorff
If GA enables you to filter based on HTTP header, then you could use page.customHeaders . - Artjom B.
I think I am going to filter based on the user's language. For some reason the browser name for PhantomJS is Safari so that wont work. The language code seems to be 'C' for all bots including the PhantomJS clients. In my case I don't care for any bot traffic so this works. - ScottOBot

1 Answers

0
votes

Solved this issue with a simple language filter (Filters->Advanced->Exclude->Filter Field "language") that excludes all clients with the language code 'c'. This worked because almost all automated bots including those running PhantomJS have a language code of 'c'.