Lucas Castellani Lucas Castellani - 20 days ago 8x
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?


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 ""