- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
06-24-2015 07:02 AM - last edited on 10-07-2015 05:09 PM by akshata_yerdoor
I'd like to fire a GA event whenever a site (www.example.com/example) is loaded and contains a certain element (the class "sucess-msg").
I imagine writing something like:
if(document.getElementsByClassName("success-msg").length){
_gaq.push([...])
}
What extension can I use for that? How do I set it up to only be active on a specific site?
Thanks
06-26-2015 03:16 PM - last edited on 10-07-2015 05:10 PM by akshata_yerdoor
Hi Mohamed,
You can use the utag.link call. You can implement this using the JavaScript Code extension and scope it to DOM Ready. It would look something like the following:
if (b['dom.url'] === 'http://www.example.com/example' && document.getElementsByClassName("success-msg").length))
{
utag.link( { event_category:"button", event_action:"click" } );
}
07-01-2015 08:31 AM
07-08-2015 12:00 AM
Copyright All Rights Reserved © 2008-2023