I want to set site section variables based on pathname tokenizer values, e.g., site, section, subsection1, subsection2, and concatenate them into a page name. I'm using Join Data Values extensions with conditions to set these variables if the pathname value is populated - site+section+subsection1+subsection2 if subsection2 is populated, site+section+subsection1 if subsection2 is not populated, site+section if subsection1 is not populated, etc. Just want to see if anyone has an easier way of doing this in Tealium. Thanks.
Without knowing what values are for 'site' and 'section' this would be an example for concatenating the domain name to the pathname with the "/" removed using regex:
// original url = https://somedomain.com/directory1/file1.html
utag_data.site_section = window.location.host;
utag_data.site_section += window.location.pathname.replace(/\//g,'');
site_section would be set to "somedomain.comdirectory1file1.html".
I referenced the utag_data object above as you would need to in a preloader for a load rule, but if used in an extension scoped to a tag you should reference the 'b' object.
If you can give more specifics for the values used and an example of the final string desired I could give you a more precise code sample.