2

I'm using DTM to listen for an event-based rule, named "My Custom Rule". The event type is "custom", as I'm using custom events to track actions from a 3rd party widget. This is my configuration below. It's fairly bland, and I have no conditions (yet). The custom event name is "my-widget-loaded".

DTM Manager

Within my 3rd party widget, I trigger my custom event:

document.dispatchEvent(new CustomEvent('my-widget-loaded'));

In the console, I see:

SATELLITE: detected my-widget-loaded on #documentument

But it never fires my rule, I never see a message like:

SATELLITE: Rule "My Custom Rule" fired.

I have verified that I can create custom event handlers within the console and they fire just fine.

What can I do to make my rule fire? Why isn't it working?

Scott Coates
  • 2,462
  • 5
  • 31
  • 40

1 Answers1

2

DTM (and Launch) does not properly listen for custom events when using document as the Element or Tag Selector. Use body (and document.body.dispatchEvent) instead.

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
  • This is correct. Changing to `body` worked. Is there any documentation for this? This would have saved some time. Additionally, I had to check the box `Apply event handler directly to element`. – Scott Coates Nov 13 '18 at 17:04
  • Not that I know of. I just found out from dealing with similar issue and poked at the DTM library to see what it did. – CrayonViolent Nov 14 '18 at 03:37
  • 1
    That's impressive! I was digging in their minified code and wasn't getting anywhere. – Scott Coates Nov 15 '18 at 04:06