Endless conversion event loop error when using below code in â Java Script Extensionâ .

manish_dixit
Silver Contributor
Silver Contributor manish_dixit
Hi, I am using the below code in Java script extension to fire CoreMetrics conversion event on load of page. if(b.page_id =="Test1"){ var newsletter1_event_data = utag_data; newsletter1_event_data.event_id = "example1"; newsletter1_event_data.event_category="example2"; newsletter1_event_data.event_type = "conversion"; utag.link(newsletter1_event_data); } 2 issues when this code execute on page: 1- Endless conversion event loop error when using above code in â Java Script Extensionâ . 2- No CoreMetrics page view tag fires on load of page
5 REPLIES 5
Highlighted

Endless conversion event loop error when using below code in â Java Script Extensionâ .

Tealium Employee
Hi Manish, You'll need to wrap this code in an additional "if" statement to prevent it from firing on a link event: if (a === "view"){ //your code here } The problem is that the extensions are running once for the page view, and then again for each link event. When you fire your link event, you therefore get an endless loop of link events, which you can only prevent by using the code above. This may also fix the pageview issue for CM. Craig.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

Endless conversion event loop error when using below code in â Java Script Extensionâ .

manish_dixit
Silver Contributor
Silver Contributor manish_dixit
Thanks Craig, I am able to fix endless loop problem, but 2 conversion events fires on load of page also page view is still not working.

Endless conversion event loop error when using below code in â Java Script Extensionâ .

manish_dixit
Silver Contributor
Silver Contributor manish_dixit
Hi Craig, I have one additional question: How to setup the code if fire events based on â jquery selector valueâ (on show, mousedown, click etc) in Java script extension. Because in most of the cases we are firing the tags based on â jquery selector valueâ . Can you please add some sample code?

Endless conversion event loop error when using below code in â Java Script Extensionâ .

jared_hislop
Employee Emeritus
jared_hislop
Manish, In your first comment to Craig you say, "but 2 conversion events fires on load of page." Isn't this what you were wanting originally in your support ticket and in this post: https://community.tealiumiq.com/questions/61231 ? Do you have a page where we can see what is happening? The pageView tag should fire automatically when the utag.js file is loaded. Your second question, Firing based on jQuery Selector Value: You would use a jQuery onHandler extension to define the element you want to track. Then you would set the proper variables. In the launchpad.americangirl profile you are using: event_id, event_category, event_points, and event_type for the main conversion event variables. So you would need to define each of those variables and make sure they are mapped back to the correct CoreMetrics value. Then when the extension is triggered by a click, mousedown or whatever event defined, those values will get assigned and the mappings will tell the template to trigger the event. Similar to the original question, are you wanting multiple events triggered on the same trigger? So two events for one jQuery onHandler extension?

Endless conversion event loop error when using below code in â Java Script Extensionâ .

jared_hislop
Employee Emeritus
jared_hislop
Another thought, the code you pasted above should be in an extension scoped to DOM Ready. The reason is DOM Ready has a flag that will check if that extension has run already. If it has then it won't run again. Other scopes do not have this flag. It looks like currently this extension is scoped directly to the CoreMetrics tag.