javascriptgoogle-analyticsanalyticsmeasurement-protocoluser-tracking

How can I send userId using the old ga.js?


Using something that's forcing us to use the old Google Analytics code. And we're wanting to track some offline events using the measurement protocol and combining it with a userID so we can track keyword performance right through to user behaviour after they register.

So I want to know how to do this, if we can't do it through the ga.js then what can we do?

I know we can do this: _gaq.push(['_setCustomVar', 1, 'Section', 'Life & Style', 3]);

But not sure if this will work when we get to the measurement protocol part on server side to match sessions and users for analysing their entire life cycle and journey with their original referring keywords or landing pages when they first found the app.

Show if we can't do this using this version, then what else can we do? Or is there a better way to achieve the above>?

Thanks!


Solution

  • You cannot send the userId with ga.js. This is not a supported feature in that version of the tracking code.

    You could set a custom variable in the ga.js code, a custom dimension via the measurement protocol, pull the respective data sets via the API and try to join the values in an external tool.

    However this would not give you any of the advantages of the userId (no session unification in the interface etc.), it would be quite cumbersome and even for a moderately large site you would run into API limits pretty quickly.