Highlighted

jQuery onHandler Extension for Click Event issue - Omniture

Tealium Employee
I am trying to tag an html button in my local environment with a jQuery onHandler extension. The code is very simple - input id="testButton" type="button" onclick="window.open('https://www.lfg.com')" value="LFG Home" /> I am using #testButton as the jQuery selector Trigger On: click Tracking Event: link Setting event_name to Text = On Click Then mapping event_name to prop 1 and event 1 For some reason the event will not trigger on click. Any ideas? Am I required to use linkTrackVars and linkTrackEvents considering that we use omniture? Also, I have noticed that when this extension is enabled it will not be recognized by the web companion.
6 REPLIES 6

jQuery onHandler Extension for Click Event issue - Omniture

robert_alderson
Not applicable
robert_alderson
Hi James, Does the onClick event send the user to a new page within the same window? If so, it could be that the page is redirecting before the event has time to fire. This is often the case with Google Analytics, and the Google recommends having a delay of around 200ms before redirecting. The same principle may well apply to Omniture. Could this be the issue here? Rob

jQuery onHandler Extension for Click Event issue - Omniture

Tealium Employee
Thanks Rob! I am opening in a new window. input id="testButton" type="button" onclick="window.open('https://www.lfg.com')" value="LFG Home" /> It is interesting however that the extension does not show in the Tag Companion either.

jQuery onHandler Extension for Click Event issue - Omniture

Tealium Employee
Hi James. I believe the issue is because of using "click" as your trigger event. I changed the trigger to use "mousedown" and on a mock page I created I now seeing the event fire and make the call to SiteCatalyst. The only real downsides to use mousedown are: - If a user clicked down on a link and then moved the mouse off the link before releasing it, then the event would be recorded even though the user hadn't visited the link - If a user used the tab key to move the browser focus to the link and then hit enter, the click would not be recorded - Mousedown also tracks middle and right clicks None of these are too common, so I would not be terribly worried about them.

jQuery onHandler Extension for Click Event issue - Omniture

Clint
Employee Emeritus
Clint
Dan, any idea of why the onHandler extension would fail using the click event vs. mouse down?

jQuery onHandler Extension for Click Event issue - Omniture

Tealium Employee
Typically an existing "onclick" handler and a Tealium jQuery onclick handler may conflict. There are probably some cases where two onclick handlers do not conflict with each other, but the assumption should be that they will. Usually there is not going to be a conflict with mousedown as they happen sooner than onclick. Tealium suggests using "mousedown" as the best practice when adding events to links. An example where they may conflict: the page may have existing onclick logic that runs first and that means the Tealium jQuery onclick handler never runs.

jQuery onHandler Extension for Click Event issue - Omniture

Clint
Employee Emeritus
Clint
Ahhh! Thanks for the insight!