Reputation: 21
My company has recently changed the way we deal with affiliates in the URL structure.
The old format: subdomain.website.com/page/?a=affiliate
with hostname subdomain.website.com
New format: affiliate.subdomain.website.com/page
with hostname affiliate.subdomain.website.com
Is there a way (ideally in Google Tag Manager) to change the hostname being passed such that the affiliate part (if present) is stripped out?
More info: Not all visitors to the website come from affiliates. The issue I am facing is that the hostname for affilaites being passed in the data layer is different to what it used to be and is unique for each affiliate that we work with. This causes lookup tables (e.g. for analytics ID) not to work as they don't match the hostname anymore. It would be impossible to keep the lookup tables updated for each new affiliate added so I'm looking for a way to strip the affiliate
part of the hostname to keep all hostnames consistent on this journey.
Upvotes: 1
Views: 470
Reputation: 32770
Sure. In your Google Analytics settings (either in your tag, or, if you use that, in your settings variable you can set the hostname field in the "fields to set" section.
If you have a single domain you just could set a constant value for the hostname. If you still have (non-affiliates) subdomains you need to track you still need a variable for that, and since it is not feasible to have a lookup table for all affiliate values you would go the other way round and whitelist the hostnames you want to keep (e.g. creating a lookup table with hostname as input that returns your cleaned up hostname as default value, and the original input for the hostnames you want to keep):
The above will return the hostname as entered for the three subdomains, and a default for everything else, thus creating a whitelist.
Upvotes: 1