This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
For example, say I have a rule, and in that rule, I want to check that both:
1. The Data Layer has completed, which I can tell by a direct call
2. The windowLoaded event has been fired by the browser.
I though of doing in a custom event, and I understand how to check for windowLoaded, but how do I check if the direct call happened too?
Solved! Go to Solution.
Views
Replies
Total Likes
Have one Rule with 2 Events:
Include one custom code Action:
// get the list of previously detected event types
let windowLoadedAndDirectCall = _satellite.getVar("window-loaded-and-direct-call");
// transform the list of previously detected event types into an array
// if there have not been any previously detected event types, then create an empty array
windowLoadedAndDirectCall = windowLoadedAndDirectCall ? windowLoadedAndDirectCall.split(',') : [];
// get the current triggered event type: "window-loaded" or "direct-call"
let eventType = event.$type;
// append the current triggered event type to the list of previously detected event types
windowLoadedAndDirectCall.push(eventType);
// remember the list of previously detected event types
_satellite.setVar("window-loaded-and-direct-call", windowLoadedAndDirectCall.join(','));
// check if both event types have been triggered
if (windowLoadedAndDirectCall.indexOf("window-loaded") > -1 && windowLoadedAndDirectCall.indexOf("direct-call") > -1) {
// send your Custom Event here
}FYI:
Views
Replies
Total Likes
Have one Rule with 2 Events:
Include one custom code Action:
// get the list of previously detected event types
let windowLoadedAndDirectCall = _satellite.getVar("window-loaded-and-direct-call");
// transform the list of previously detected event types into an array
// if there have not been any previously detected event types, then create an empty array
windowLoadedAndDirectCall = windowLoadedAndDirectCall ? windowLoadedAndDirectCall.split(',') : [];
// get the current triggered event type: "window-loaded" or "direct-call"
let eventType = event.$type;
// append the current triggered event type to the list of previously detected event types
windowLoadedAndDirectCall.push(eventType);
// remember the list of previously detected event types
_satellite.setVar("window-loaded-and-direct-call", windowLoadedAndDirectCall.join(','));
// check if both event types have been triggered
if (windowLoadedAndDirectCall.indexOf("window-loaded") > -1 && windowLoadedAndDirectCall.indexOf("direct-call") > -1) {
// send your Custom Event here
}FYI:
Views
Replies
Total Likes
Thanks for the code - I'm a little confused at what I put here?:
// get the list of previously detected event types
let windowLoadedAndDirectCall = _satellite.getVar("window-loaded-and-direct-call");What goes in the Data Element ("window-loaded-and-direct-call")
that indicates an event has occurred already? - I think that's my challenge ...is I can't tell if a direct call occurred from within a rule, so I can't check it for its existence?
Views
Replies
Total Likes
The code that populates this "window-loaded-and-direct-call" Data Element is in the next few lines:
// get the current triggered event type: "window-loaded" or "direct-call"
let eventType = event.$type;
// append the current triggered event type to the list of previously detected event types
windowLoadedAndDirectCall.push(eventType);
// remember the list of previously detected event types
_satellite.setVar("window-loaded-and-direct-call", windowLoadedAndDirectCall.join(','));
Notice the use of "event.$type". This is a property in the "event" object that all Launch events return automatically.
Hope that helps!
(BTW I updated my original answer. I realised that I had forgotten to "split" the Data Element's value after reading it, so that its comma-separated values become an array properly.)
Views
Replies
Total Likes
Thanks for all this!
Views
Replies
Total Likes
Views
Likes
Replies