0

I have come across this peculiar behaviour of GTM's dayaLayer code. The below issue happens to me only in firefox browser and all other browsers work fine - (Edge and Chrome).

I have a dataLayer.push code in my javascript file - which pushes a ecommerce event. After which I have a redirection code in javascript function using - window.location.

Only in firefox this code : dataLayer.push followed by window.location doesn't fire. I tried with GTM preview and event is not pushed to data layer.

How else can I make it to work in firefox browser ? Thanks in advance.

Below is my javascript function code :

function SendEventToGTM(items, event, userName, urlToRedirect) {
        window.dataLayer = window.dataLayer || [];
        window.dataLayer.push({
            ecommerce: null
        });
    
        window.dataLayer.push({
            event: event,
            ecommerce: {
                items: items,         
                userName: userName
            },
        });

    if (urlToRedirect!= "" && urlToRedirect!= undefined && urlToRedirect!=null ) 
        {
           window.location = urlToRedirect; **// issue is with this statement**
        }
    
    }

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.