Lucas Castellani Lucas Castellani - 1 year ago 86
Javascript Question

Pass root domain to JS Script

I want to replace with my root domain

ga('require', 'linker');
ga('linker:autoLink', ['']);
ga('send', 'pageview');

How can I get the root domain where this code is installed and replace facebook for it?

Answer Source

The window.location object has many properties including hostname

If I understand you correctly you want:

ga('linker:autoLink', [window.location.hostname]);

On this page for example it would return ""

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download