JENTIS Data Layer State
Last updated
Was this helpful?
The jts_push_submit(cb) function is a utility used to intercept and enhance the behavior of the native JENTIS _jts.push() method. It allows custom logic (like firing callbacks, triggering events, or modifying payloads) to be executed whenever tracking data is pushed to the JENTIS Data Layer.
This is especially useful for extending or customizing the tracking behavior (e.g. triggering beacons, transforming legacy data formats, or resetting the data layer after submission).
Wraps the original _jts.push() function.
Monitors push calls, including special tracking commands like submit, event, and promotion*.
Executes a callback cb when certain conditions are met (e.g. tracking submission).
Optionally sends data using the sendBeacon method if certain commands are tracked.
_jts.push()Saves the original _jts.push() to oldFunc.
Replaces _jts.push with a new function (newPushFunc) that includes additional logic before optionally calling oldFunc.
When tracking commands like promotionclick or promotionimpression are detected, _transformPromotion() is called.
This method reads the last promotion object, transforms it into the current format, and re-pushes it as a promotion with the correct type.
The cb() callback is invoked when any of the following is true:
A track: "submit" or track: "event" is pushed.
The second argument is true (indicating immediate submission).
These are typically moments when all queued data is sent to the server.
If the track command is one of the values in arrSendBeaconConfig (e.g., addtocart, event), the function marks the request as sendBeacon.
arrSendBeaconConfigAn array of tracking types that should be sent via the sendBeacon API for more reliable background delivery.
_transformPromotion(promotionType)Transforms legacy promotion* tracking commands into the modern format and pushes the transformed object to the data layer.
_findElement(arr, target)Simple helper function to check whether a specific value (target) exists in an array (arr).
optionalParamObjAn object passed to the callback containing:
A stateCallback used to reset the window._jtsDataLayerContext.
An optional requestType (e.g., sendBeacon) when applicable.
If the _jts array already contains items (i.e., data was pushed before the override), they are immediately passed through the new push function to ensure consistent processing.
You might use jts_push_submit() to trigger custom logic (e.g., analytics logging or DOM manipulation) every time a submission occurs:
The jts_push_submit(cb) function is a powerful hook into the JENTIS data layer that allows developers to:
Monitor and enhance tracking behavior
Transform legacy tracking formats
Trigger custom logic upon data submission
Utilize modern delivery methods like sendBeacon
It provides an elegant way to extend the functionality of JENTIS without altering the default data capturing mechanisms.
Last updated
Was this helpful?
Was this helpful?
["event", "addtocart", "removefromcart", "addtowishlist", "removefromwishlist", "productlistclick", "promotionclick", "promotionimpression"]if (typeof _jts === "object") {
for (...) {
newPushFunc(_jts[i]);
}
}jts_push_submit(({ stateCallback, requestType }) => {
// Custom logic on submit/event
console.log("Data layer submitted");
stateCallback(); // Reset the current context if needed
});