Run code after _satellite.pagebottom or _satellite.track are completed in callback or Promise




I was wondering if it is possible to run any code after the async functions _satellite.pagebottom or _satellite.track are complete. We need to navigate user to another page and as I saw running a rule with _satellite.track is making async http requests. Obviously if I just add window.replace after _satellite.track it will cancel those requests and rule would not be executed. What we need is either some kind of callback in _satellite.track function or for it to return a Promise (currently it returns undefined). Right now I am relying on setTimeout and hoping that _satellite.track will finish within the number of seconds set in setTimeout but that is very ugly and hack solution. We need callback or Promise that will assure us that _satellite.track is complete.

Please advise. Thank you.

Best regards,

Goran Blazin

Sprinting Software

Accepted Solutions (0)

Answers (1)

Answers (1)



We ran into something similar with click tracking mboxes in target.

our solution was to override the onclick and href values of the element clicked, then in the success AND error states of the click tracking call, we then created a new dom a tag on the fly, added the href back for the next piece of js to use the window.location change.

works well, kinda hacky, but that's what we had to do in order to deal with the window.location changes

better way is to not do the window.replace and instead rely on native browser element functionality for changing the location. depends on your setup. we aren't on a SPA site with angular, but we have a lot of ajaxy reqs.

``` code

var clickTrack = function(click){



                            'preventDefault': true,

                            'params': {

                                'menuClick': click


                            'success': function(){

                                jQuery(this).attr('href', href);

                                location.href = jQuery(this).attr('href');


                            'error': function(){

                                jQuery(this).attr('href', href);

                                location.href = jQuery(this).attr('href');


                            'timeout': 750