How the autoLink plugin works (analytics.js)
When you add the autoLink plugin to your tracking code, it automatically loads with your pages and performs a substring match on all your links. It then recognizes any links that include a domain name you’ve specified in your tracking code. Any traffic that clicks a link to those domains get counted as cross domain traffic.
For example, if you have set up cross domain tracking on example-1.com and example-2.com, the autoLink plugin recognizes links on example-1.com that go to example-2.com. When a user visits a page on example-1.com and clicks a link to example-2.com, the autoLink plugin counts the navigation as cross domain traffic.
It’s possible to have pages that are set up in ways that stop the plugin from working. You should test the plugin on one page before implementing it on your entire site.
To set up the autoLink plugin, you must add the plugin to your tracking code snippet, define the domains you want to track, and tell each page to allow the plugin to run.
- Cross-Domain Tracking - Web Tracking (analytics.js developer documentation)
- Cross-domain tracking with Google Tag Manager