Let's say I have a landing page URL that is not on my own site, www.notmysite.example/somepage
and I want to advertise this link. I would like to create a URL that is tracked through my G4A Tag Manager, whereby the link click, referrer, etc., are all tracked in a G4A campaign.
Create a
redirect
CUSTOM JavaScript variable that reads theurl-redirect_parameter
variablefunction() { try { return {{url-redirect_parameter}}?setTimeout(function(){window.location='{{url-redirect_parameter}}'},500):false; } catch(e) { return e; } }
This custom JS variable references a redirect tag with the following configurations
What this captures now is whenever there is a "redirect=" in the query string, the trigger will fire, record and redirect.
Another solution is just to add UTM parameters to a page you control on your site and have code on that page to auto-redirect to a QS parameter as well. This essentially does just that by injecting JS that does the redirect if the QS is present.
I hope his helps someone else looking for a similar solution and open to other solutions, like a G4A solution.
Here is the Universal Analytics result: