How to trigger custom event in adobe launch rules | Community
Skip to main content
susheel
New Participant
January 8, 2019
Solved

How to trigger custom event in adobe launch rules

  • January 8, 2019
  • 11 replies
  • 25398 views

We have a scenario where a custom event would be triggered. Now I want to fire a tag when the custom event is triggered. What I did is:

  1. Created a new rule.
  2. In events section I used Custom Event from the dropdown.
  3. filled Custom Event Type with email_submit(This is the custom event triggered via $(window).trigger('email_submit')).
  4. In then section I am triggering one of the extensions(DoubleClick Floodlight).

Note: if the use page top event then everything works fine but not with custom event. Please let me know If I am doing something wrong.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by susheel

For now I have done as below. I will keep on adding all events as I find.

$(window).on('event1 event2 event3',function(e) {

  document.body.dispatchEvent(new CustomEvent(e.type));

});

11 replies

Stewart_Schilling
New Participant
January 8, 2019

There are a few things that I'd try. 

1) I tend to use vanilla JS.  Try one of these (from the JS console) to see if it solves the issue.

Try this if you want to pass a detail payload with the event.

  window.dispatchEvent(new CustomEvent("email_submit", {
  detail: { foo: "1", bar: "2" }
  }));

Or this if you just want the event triggered.

  window.dispatchEvent(new CustomEvent("email_submit"));

Note that if you need to support IE 11, there is a polyfill required for `CustomEvent`.  You'll find it here: https://gomakethings.com/custom-events-with-vanilla-javascript/

2) In DTM, you could not catch a custom event on `window`.  I'm not sure if that's still the case with Launch.

Try dispatching on `body` or any element of your choice.

  body.dispatchEvent(new CustomEvent("email_submit", {

  detail: { foo: "1", bar: "2" }

  }));

You'll need to update your rule in Launch to trigger on `specific element` and `body` as shown below.