I have a couple of problems with implementing Google Analytics to record traffic across two domains using the same analytics account I just can't seem to solve. I have a website running Google Universal Analytics which works fine. The site has links on to an external 'course application' website. I would like to be able to track traffic across these two domains. I know that the usual way to do this is with the Auto linker plugin. However that works by adding a variable onto the url of the second site; unfortunately the second website does not allow additional variables to be added to the url as it carries other info in the query string for its sign up process which errors.
Is there an alternative way to link the analytics data for multiple domains into the same Google Analytics account without using the Autolinker plugin? I guess using cookies is not possible because of the limitation of passing info across domains.
Also is there a way to limit this data to populate the Analytics account only if the visitor has come from my website and not from any other? The secondary 'course application sign up' website is linked to from a number of other websites as well as the one I am working on. Any ideas? thanks
You can also pass parameters in the anchor part of the url.
ga('linker:autoLink', ['destination.com', 'dest3.com'], true);
The true
parameter at the end is the magic here. It will pass parameters in the anchor instead of query parameters. The final url will look like this:
//destination.com#_ga=1.182119591.1441315536.1362115890410
More info: https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain
You still need to use 'allowLinker': true
on the destination website.
If that doesn't work for you, then you are out of luck. You will have to change the destination site to either ignore these parameters or anchor.
As for your second question. GA doesn't have a function that says only track me if I come from siteX, but you should be able to do that yourself. My first suggestion would be to use a query parameter when you link to the site saying that the user comes from siteX, but I suppose that won't work given your problem with query parameters. Another option is to check document.referrer
, if that is your site, than set a cookie saying that user came from siteX and then only fire your Google Analytics tracker if the cookie is set.