Using JQuery onhandler to Fire Tag on Event but on certain pages, is this possible?

Silver Contributor
Silver Contributor
So here is my scenario: Our advertising partners want to track anytime a video is played on our website. I am using the JQuery onhandler to do this and targeting the div class of the video modal. The tag works fine. So here is my problem, we have multiple website channels (same base domain but separate breakout) and we use on Tealium account to manage all tags. Our advertising partners want to use separate tags to track videos but the code (div class) is the same for all the different website channels so tag fires on all channels. My question: Can you make a tag fire using the div class of an object but only when the URL or some other factor meets a certain requirement/condition? The tag is a floodlight tag in case that changes things. Thanks in advance for any help on this problem!
3 REPLIES 3

Using JQuery onhandler to Fire Tag on Event but on certain pages, is this possible?

Employee Emeritus
Hi Dustin, Thanks for your question. I'm afraid the jQuery extensions don't have any capability to run conditionally (i.e by URL). The only way to really try to limit this is to use a selector which is able to use an element on the page to help you refine it. What I would do is write my own jQuery in a 'javascript' extension scoped to 'dom ready'. For example: if(document.location.href.indexOf('YOUR CRITERIA) > -1){ jQuery(document.body).on('mousedown','#divid',function(e){ utag.link({ event_name:'great event', event_detail:this.href }); ); } If you have any questions it might be worth reaching out to your local support team for assistance. Hope this helps! Cheers, Roshan

Using JQuery onhandler to Fire Tag on Event but on certain pages, is this possible?

Tealium Employee
Hi Dustin, The other option is to select custom in the event dropdown of the click handler extension. This will allow you to add custom code where you can have if statements to check that the page is correct and if you have a newer version of utag.js you can call the specific tag that you interested in. Personally I would look to making the selector specific enough that it only matchs what you are interested in tagging.

Using JQuery onhandler to Fire Tag on Event but on certain pages, is this possible?

Employee Emeritus
At one point this was being worked on by engineering, not sure where they are on this topic. I will ping them again with this customer request. Thanks Dustin for the question and thank you Simon and Roshan for a solution. Putting this type of logic in the the UI is the correct long term approach.
Public