cool_kid
cool_kid

Reputation: 347

Google Analytics Cross Domain Tracking does not work

When a visitor tries to do a booking, the site directs him/her to the booking engine site.

ga('create', 'UA-XXXXXXXX-Y', 'auto', {'allowLinker': true });

ga('require', 'linker');

ga('linker:autoLink', ['mysite.com', 'bookingengine.com'], true, true);

ga('require', 'displayfeatures');

ga('require', 'linkid');

ga('send', 'pageview');

There are no errors or warnings.

I used a cookie monitor and it shows that browser creates another new _ga cookie when it loads the booking engine site. The same cookie ID is not used.

I was struggling for days changing code to ga('linker:autoLink', ['mysite.com', 'bookingengine.com'], false, true); but it did not work.

Upvotes: 0

Views: 995

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32780

Okay, I see the problem. If you fill in the form on your main site and click you see the _ga parameter is not appended to the url that calls the booking-engine. Since the parameter is necessary to transfer the clientid to the other site, where it is picked up by GA and used as clientid, cross-domain tracking cannot work - the GA code on the booking-engine does not find a _ga parameter in the incoming url and so starts a new sessions.

Usually the autolink plugin would add the parameter to the forms action. This does not work in your case since the form is actually submitted via a JQuery function (bookNow() in your functions.js file). This prevents the linker function from intercepting the submit event and adding the parameter.

The solution would be to add it yourself - get the linker parameter from the tracker object (tracker.get('linkerparam')) and add it to the form action and add it to the redirect url in the booknow() function.

Upvotes: 2

Related Questions