Want to capture only url after # in page url
I want to capture url after #tag in page url, how should i set it up in data elements in tag manager.
So i have created variable Article and i want to store variable article1, article2.. so on.
I want to capture url after #tag in page url, how should i set it up in data elements in tag manager.
So i have created variable Article and i want to store variable article1, article2.. so on.
I don't think there's a default standard data element for this, but you can get it using a Custom Code data element using window.location.hash
return window.location.hash
OR if you need to sanitize the data, or check for values before returning the final value (since often links from FB or other external source could add hash values to your URLs that may not be your "article" values, or if there are any named anchors used in your site like accessible "skip links", or "back to top", etc links that all use #):
var hash = window.location.hash;
// Do sanitation and checks here
return hash;
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.