- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
01-27-2015 06:01 AM
01-28-2015 11:19 AM - last edited on 10-07-2015 04:52 PM by akshata_yerdoor
Hi Jarno,
If you are checking one event, then you can use the indexOf syntax. Something like so:
if(b['pageEvents'].indexOf('XXX') > -1) { u.addEvent('YYY'); }
If you want to check multiple events at a time, you'll probably want to do a loop and go through all the different events. Maybe something like so:
var pageEvents = "eventA,eventB".split(","); for(key in pageEvents){ if(pageEvents[key] == "eventA") u.addEvent("XXX"); else if (pageEvents[key] == "eventB") u.addEvent("YYY");
}
I personally like to use the object syntax though it is more complicated:
var events = {
eventA: "XXX",
eventB: "YYY" };
var pageEvents = "eventA,eventB".split(",");
for(key in pageEvents){
if(events[key]) u.addEvent(events[key]);
}
01-28-2015 11:22 AM - last edited on 10-07-2015 04:49 PM by akshata_yerdoor
Hi Jarno,
In order to do what you describe, the approach I would take is to create a separate extension for each event. So the process would be:
1. Create set data value extension, scope it to your SiteCat tag
2. Set the 'condition' to your contains condition. For example, variable 'pageEvents' CONTAINS 'prod-out-of-stock'
3. Create a var named sc_events and set the value to JS code
4. Set the JS code value to: u.addEvent(["event1","event2","scView"]); or any other events you'd like to fire on this condition.
5. Repeat 1-4 for any other 'condition' you'd like to fire other events on.
If you can't get this to work please contact your Account Manager so we can help you through this.
01-28-2015 11:37 AM
01-28-2015 06:31 PM
01-29-2015 03:51 AM
01-29-2015 07:36 AM
02-09-2015 05:41 AM - last edited on 10-07-2015 04:47 PM by akshata_yerdoor
I realized now that u.addEvent should be used only as scoped with a specific tag, and it makes sense because the name of events are only related to specific tag.
I'd like to create something at very top level, available for all tags.
Probably I need an array:
Events['Order']=['enabled'=1, 'fired'=0, 'sitecatalyst'='purchase', 'googleanalytics'='customX']
then I use an extension (tag scoped) to fire u.addEvent within a loop as you suggested.
am I in a right way?
02-10-2015 11:38 AM
Copyright All Rights Reserved © 2008-2023