- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
Hi,
I have a url like this https://example.com/xxxx/xxxxx/product/12345. I want to extract only 12345 from the url and assign it to other variable. How do i acheive this in Tealium iQ?
Hi Mageshsm
If the url structure there is always consistent. You could add the Tealium Extension, Pathname Tokenizer
This would then create 4 utag_data variables on these pages with the value you are looking for in
utag_data._pathname4
If you have a extension that is a library of functions, you could add a function. There are many ways this could be done, just depends on how tight the logic needs to be as well as the circumstances on when/where you call it.
Simple example:
lookForProductID = function() { var str = window.location.pathname.split('/'); if (str[str.length - 2] === 'product') { return str[str.length - 1]; } } prodID = lookForProductID();
Cheers
Kevin
Copyright All Rights Reserved © 2008-2023