Load order

Depending on how you integrate LiftIgniter, there may be issues with the load order between different components of the page. The various possible issues, and ways to address them, are discussed below.

1. LiftIgniter SDK functions called before LiftIgniter snippet loads

You need to make sure that you execute LiftIgniter SDK functions (the $p functions) after the LiftIgniter snippet is executed.

It is not necessary for the actual Javascript file loaded by the snippet to be fully downloaded before you can call the SDK functions. This is because the snippet contains logic to maintain all $p calls in a queue until the full Javascript file is available.

However, it is necessary for the snippet itself to be executed, otherwise your browser has no idea what $p is referring to.

If you are using Google Tag Manager for the snippet, but calling the SDK functions outside of Google Tag Manager, things can get tricky, since Google Tag Manager itself loads asynchronously (so it is not guaranteed to have executed the snippet by the time you call the SDK functions). We therefore recommend that you put our snippet in the HEAD of your raw page HTML directly, or you use some other method to make sure that GTM has executed the snippet before you run SDK functions.

2. LiftIgniter recommendations are trying to overwrite a widget that hasn't loaded

If you are Overwriting Widgets (that already have recommendations) with LiftIgniter recommendations, the overwriting logic should be executed after the widget being overwritten has loaded. Note that you can still register and fetch recommendations before the widget has loaded, as long as you know how many recommendations to fetch.

If you have jQuery installed, you can wrap your overwrite callback inside jQuery. This will work if your base recommendations are being loaded as part of the DOM. An example is provided below.

                max: 3,
                widget: 'your-widget-name',
                callback: function(resp) {
                                        jQuery(function() {
                        // track overwritten areas as 'LI' slice.

If your base recommendations that you want to replace are not part of the DOM, you will have to figure out a way to determine if they have loaded. In the worst case, you can just wait a fixed amount of time using Javascript's setTimeout function before executing the overwrite callback.

3. Tracking is being called before the recommendations are loaded

For LiftIgniter recommendations, you need to make sure that the call to the track function happens after the rendering logic, within the same callback. Then, as long as the rendering happens correctly, the tracking will happen correctly. In particular, if you have wrapped the rendering logic inside a jQuery or any other listener, you should put the tracking logic after the rendering logic inside the same callback.

For the base recommendations, you need to make sure that the call to the track function happens after the base recommendations have loaded. Similar to the example in Section 2 for overwriting, you can use jQuery to detect page load. This works if the base recommendations are loaded as part of the DOM.

// track marked areas as 'base' or original slice.
        jQuery(function() {