Rich-text Reply

Custom events always being sent to one version

naltimari 07-11-14

Custom events always being sent to one version

Hi,

 

I'm using an Optimizely custom event to track a Vimeo video play. Vimeo uses a special JS event library called 'Froogaloop' (or something like that), so I hooked a javascript function to the 'play' event and then I send the custom event to Optimizely, using window.optimizely.push(['trackEvent', myCustomEventLabel]).

 

The custom event is being fired, however Optimizely is  only registering it on version A. Version B has no record whatsoever. It would be impossible for people not to be clicking on the video on version B, so something must be wrong with the way Optimizely is identifying the version which is currently active on the browser.

 

Any tips on how can I debug/solve this?

naltimari 07-11-14
 

Re: Custom events always being sent to one version

I think I found the problem. There's two instances of the video, and each variation hides one and shows the other via javascript. However the event binding was being applied to both nodes, but since they use the same DOM ID, probably the second is overriding the first.
Amanda 07-11-14
 

Re: Custom events always being sent to one version

Hey there! I took a look at your page and played the video on both the original and the variation. I saw the event "wat-is-bliep-play" trigger for both versions, so it sounds like you have everything sorted out now!

 

Out of curiousity, what did you do in order to resolve the issue? Did you bind the event using a more specific DOM ID? Also, if you could post the JavaScript you are using with the event bound to the "play" action, I am sure this would be incredibly helpful for other community memebers who are hoping to do the same thing. 

 

Looking forward to hearing back from you Smiley Happy

Optimizely
naltimari 07-13-14
 

Re: Custom events always being sent to one version

Actually it was not an issue with Optimizely at all, it was a problem with the DOM, like I said before.

 

Instead of using Optimizely's HTML editor to insert/replace content, I created a page with both 'versions' and used Optimizely just to switch between them, using javascript. This enables us to keep all the code in our codebase, versioned, and test more easily. So, in order to have both 'A' and 'B' parts on the same page, I ended up with two elements that had the same ID. I could only understand the situation when I figured that out.

 

To actually solve the issue, I inserted a 'setTimeout' javascript that waits 50ms, then I applies the event binding to the video which has the ':visible' pseudo-class.

 

I guess the problem has to do with the Froogaloop plugin (which Vimeo uses) being confused when it gets binded to two elements that have the same ID. But there should not be two elements with the same ID on the page, anyway.

Amanda 07-14-14
 

Re: Custom events always being sent to one version

Great to know! Thanks for the update.
Optimizely