내 커뮤니티 업적 표시줄을 확대합니다.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Calling a Custom Event Without CSS Selector

Avatar

Level 4

Hello,

I'm trying to create an event rule for a page where most events are driven by ReactVR objects, not by DOM API or CSS.

I know that I can create a custom event, and track a click that way. (I found the answer here) But, because there aren't any CSS selector to latch onto, I'd like to know if and how I can get around having to use the CSS selector or if there's a trick for that.

Thanks in advance!

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 9

If you want to use this type of Event Based Rule, you can use body as the CSS selector:

chrome_2017-11-01_19-48-35 - Copy.png

I don't know how ReactVR works so I don't know what you do for creating/dispatching custom events, so here is a pure js example:

var myEvent = new CustomEvent('myEvent', { foo : 'bar' });
document.querySelector('body').dispatchEvent(myEvent);

Alternatively, you may consider creating a Direct Call Rule (DCR) instead.  A DCR takes a single string value as a condition, e.g. "foobar" (no quotes).  Then you simply call it like so:

_satellite.track("foobar");

원본 게시물의 솔루션 보기

3 답변 개

Avatar

정확한 답변 작성자:
Level 9

If you want to use this type of Event Based Rule, you can use body as the CSS selector:

chrome_2017-11-01_19-48-35 - Copy.png

I don't know how ReactVR works so I don't know what you do for creating/dispatching custom events, so here is a pure js example:

var myEvent = new CustomEvent('myEvent', { foo : 'bar' });
document.querySelector('body').dispatchEvent(myEvent);

Alternatively, you may consider creating a Direct Call Rule (DCR) instead.  A DCR takes a single string value as a condition, e.g. "foobar" (no quotes).  Then you simply call it like so:

_satellite.track("foobar");

Avatar

Employee

Leo Shvedsky

Does the previous reply answer your question? If so, would you mind marking it as the correct answer?

Cheers,
Jantzen

Avatar

Employee

This worked for me within the context of just pure JS on an AEM site. There was an existing function that fired upon the site action I was trying to measure and I just added this event within that JS function. Listening for just the body worked great! One note is that it wasn't working until I checked the "apply event handler directly to element" check box