17

I'd like to know how active are the users depending on the source/medium/campaign of the traffic they came from before sign up. I'm hitting wall when trying to get campaign/source/medium for the current visit from Google Analytics tracker in JS.

I found this tracker.get() method: https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#get but they don't specify what are the possible values for 'fieldName'. I inspected the tracker object in Firebug and found out the screen attached screen grab:

inspection of the tracker object

Are these the only fields that I can query? Is reading any of the campaign fields possible? I understand that GA intends to be anonymous, but I figured this information is not really a secret...

If I can't retrieve this information from GA tracker, how would you approach this question? Should I set my own cookie whenever there's a visit with utm_ parameters and then read it if the visitor chooses to sign up?

I'm aware of this response: How do I extract Google Analytics campaign data from their cookie with Javascript? but a comment says parsing a cookie won't work for AdWords traffic..

Cœur
  • 37,241
  • 25
  • 195
  • 267
Marcin
  • 591
  • 5
  • 12
  • 3
    Parsing cookies for adwords tracking will not work because adwords (if autotagging is enabled) transmits its information through a click id that is resolved only on the Google servers - which means that you cannot at all get adwords campaign info clientside. Plus cookie parsing does not work with Universal Analytics which does not store info clientside (except for the client id, and sometimes not even that). – Eike Pierstorff Jan 12 '14 at 14:57
  • 1
    Google Analytics is not designed to do that. The other answer have workarounds to piggyback into GA to get this info. But it's not officially supported. If you are using the new version of analytics (analytics.js) it won't even work since the cookie doesn't carry those vales anymore, they are calculated serverside. Google Analytics is not your tool for this job. – Eduardo Feb 24 '15 at 21:49

2 Answers2

0

I had to do something similar for a project. You need to think outside of the box to get this working. This will only work for cases where you put the campagn information in the url, for tagged url's.

1) On every page add server side code(php, asp .net) to parse the querystring and save the campagn/source/medium from the url in a session(or cookie)

2) Retrieve this information where you need it and process it.

Valderann
  • 805
  • 12
  • 30
0

You indeed need some custom javascript in order to achieve this. I created an open source project for this that addresses the need quite simply: https://github.com/ilkkapeltola/visitdata

Once you include the javascript library, you can call visitdata.get() and it'll return an object with things such as source, medium etc.