3

PHP is listed as a browser in Google Analytics. 50 sessions have been created.

Screenshot of Google Analytics showing PHP as browser

Obviously Analytics data is collected via Javascript executed in the visitor's browser so what is PHP (a server-side language) doing in this list?!

My own server is PHP and there is a server-side script that records certain Events by pushing data into GA. I checked the Events report and sure enough, there was the exact same number 50, as the number of Unique Events.

Screenshot of Google Analytics showing 50 events

So we can safely assume that these stats are actually about hits on the GA API. But why are my own server-side requests to Analytics being bundled in with data which should be about the users? I look at the Browser + OS report to learn about my site's Users, surely mixing in information about my server-side requests to the API is misleading?! PHP is not one of my users browsers, it is my own server pushing user data into my Analytics account.

Is there a some parameters I can add to the API requests? Should I be capturing the User Agent string myself and passing that to the GA API? If so, do I then capture the IP Address, language et cetera, the never ending list of things GA records. Can I just tell GA not to include the information about which server is hitting the API but instead, just the information given to the API?

  • I'm seeing this same issue where "WordPress" is appearing as the Browser. I can confirm that this has to do with server-side analytics events. I'm currently troubleshooting a few ideas including adding more parameters (based on Google's Measurement Protocol), or sending a non-interaction parameter (as 'ni' => 1 in my array). – GreatBlakes Feb 26 '15 at 17:28
2

Sending a non-interaction parameter with the Event hit type seems to keep the sessions at 0. The only issue I see now is that the "New Users" column still has data in it. This does not affect the graph or the total number of hits/sessions/pageviews, but I wanted to note it.

The syntax for a non-interaction is 'ni' (boolean) where 1 is non-interaction, and 0 is interaction. I've just added this into all of my server-side event tracking with a default of true. This seems to have fixed most of the problem.

Here it is on the documentation page.

Hope this helps. It seems like not a lot of people are having this issue, so it's tough to find any clues/answers.

1

Very likely an automated script hitting your site and trigger analytics to fire. PHP can be a valid user agent, at least according to http://www.useragentstring.com/pages/useragentstring.php

I would drill down in to the PHP analytics and then view the location of those visitors, time on site, page views and more to try and determine if it's a script or person.

  • Not really added anything that wasn't in the question. It is fair to assume this strange data is about my script. The question is WHY GA is recording a script which is not a user's browser executing Javascript but my own server trying to give a specific set of data to GA. The API is recording the messenger not just the message. – Martin Joiner Aug 5 '14 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.