Getting cross-domain tracking right in Google Analytics is difficult. Even if you use Google Tag Manager. There are many known issues when cross-domain tracking iframes, for example.
Google Tag Manager implements the cross-domain tracking plugin quite handily via the Universal Analytics tag template, and often the easiest way to track links and form submits is to use the Auto-Link Domains option, as described in this great series of posts on cross-domain tracking by Bounteous.
However, sometimes you want more precision in decorating the URLs. Perhaps you only want to decorate one specific link rather than all links that share the same hostname. Or perhaps you only want to decorate forms when they are submitted by your actual visitors rather than internal users.
This is where the quite rare Decorate Links and Decorate Forms Universal Analytics tag types come in handy.
The Simmer Newsletter
Follow this link to subscribe to the Simmer Newsletter! Stay up-to-date with the latest content from Simo Ahava and the Simmer online course platform.
Tip 86: Decorate Links and Decorate Forms tags
The principle is very simple. If you set the Decorate Links tag to fire with a Just Links trigger, then any link click that causes that trigger to go off will be decorated by the tag. Similarly, if you set the Decorate Forms tag to fire with a Form trigger, then any form submit that toggles that trigger will have its destination URL decorated by the tag.
For example, if you create a Just Links trigger with the following condition:
Click URL matches RegEx shop\.domain\.com/cart/
Then any click on a link whose href
contains shop.domain.com/cart/
will be decorated with cross-domain parameters. However, unlike the Auto-Link Domains plugin, no other link to shop.domain.com will be decorated.
This can be very useful if you want full control over when Client ID information is passed from domain to domain.