1

How does google get traffic information such as the medium and source for various channels? I need to store this information into a table but I'm not even sure if this is possible or not?

Can I obtain any of the information such as the acquisition and traffic information from google analytics through server side code? Either during the duration of the tracking or am I able to abstract this information from google analytics directly... If not, how does google obtain this information? I'm sure somebody else will have tried to do this at some point?

Somebody has informed me tagging the URL is a good way around this, but if we were not to tag the URL... is this possible?

Cheers,

mwre
  • 35
  • 3

1 Answers1

2

Google gets this information primarily from the referring url information which it accesses via their javascript code that you include on your web page. They then store this information in various ways in several cookies that they set. If you use the browser's developer tools (F12) and monitor cookies for a site that uses Google Analytics you can see this happening. Here is more info on how google is using cookies from a technical perspective: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage#cookiesSet

You can do your own on-site tracking in a similar manner if you are looking for traffic info at the request/visitor level. If you are looking for aggregated traffic information google does make a lot of the google analytics data available via APIs that you can call from your server. Here is more info on their APIs: https://developers.google.com/analytics/devguides/integrate/

RonC
  • 31,330
  • 19
  • 94
  • 139
  • Hi Ron, is it possible say for example... if I make a booking or register for a site (some sort of event) during the server side call to the onclick method... Is it possible I can use a tracking id of some sort to gather this information directly from the api? It would need to be visit that is currently being tracked as the user hits the event. – mwre Jul 07 '16 at 17:02
  • On the server side you can get the referrer via the Request.UrlReferrer property. Be sure to wrap that access in a try catch block as the call will throw if the UrlReferrer data is malformed (which it occasionally is). You can learn more here: http://stackoverflow.com/questions/4258217/getting-the-http-referrer-in-asp-net Regarding use of a tracking id: last I checked google doesn't allow you to get request specific information from their APIs. – RonC Jul 07 '16 at 17:09
  • This would kind of work, I would need to add a session and keep this stored as its likely the user can navigate to other parts of the site before they reach the goal. Is there no way at all of gathering the google analytics stuff then? It would be nice to have the medium etc. – mwre Jul 07 '16 at 17:11
  • You can add session support, or store the information in a cookie so that it's available when the visitor navigates to other pages on the site. Google takes the cookie approach since they don't have access to your session even if one exists. (remember to upvote my answer and comments if useful) – RonC Jul 07 '16 at 17:13
  • Ok, so all I can obtain is the Url Referral, I won't be able to obtain any of the information that is stored in google analytics - server side only? Correct? – mwre Jul 07 '16 at 17:18
  • Correct. It's from this referring url (including any parameters) that google figures out all of the referral data. So for example if the referral is from twitter.com or facebook.com (among others) it was a social referral, or if it was from google.com or bing.com (among others) it was an organic search referral, and so on. Lastly, you may be able to get useful information from google's own cookies. Refer to the link in my original answer. – RonC Jul 07 '16 at 17:21
  • Ah great, you have been really helpful. Thanks. – mwre Jul 07 '16 at 17:24