1

It would be useful if, when placing an order or submitting a form, we could reliably include the visitor's referrer with the request. This is not always simple because, for example, the user could have found us via Adwords, left the site and come back by typing in the address. In this case, we would want to know the Adwords campaign for this specific visitor. Google Events don't fit well with our workflow.

Other questions have tried to use Javascript and apparently that is not possible. I noticed that Google sets a _ga cookie which we can read - it gives us an ID that looks like this: GA1.2.123456789.1234567890. Can we use PHP to extract the referrer according to Google from that ID?

James
  • 741
  • 1
  • 11
  • 28
  • This might be a duplicate (or is at least related) to http://stackoverflow.com/questions/17927924/how-to-get-the-referrer-paid-natural-and-keywords-for-the-current-visitor-in-ph?rq=1 (and altough my answer there was downvoted it's still correct). – Eike Pierstorff Sep 04 '15 at 14:34

1 Answers1

1

Not in realtime, no. It used to be possible with the previous version of GA which evaluated traffic sources clientside and stored the values in a cookie. However with Universal Analytics the processing is now done serverside and the information is not accessible in realtime (there is a realtime API but that'S for various reasons not feasible for getting data on individual users).

It is however possible to get the referrer data via javascript - you look at document.referer and (if the referrer domain is different from your own domain) store it into a cookie (since the question is tagged with PHP, you can do the same with $_SERVER['HTTP_REFERER']).

This will not exactly match Googles info (Google will show referrals from google properties, yahoo, bing etc. not as referrer but as organic search traffic) but should be close enough.

Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62