Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting Shopify theme's failure to fire Google Analytics 4 ecommerce events

  • Troubleshooting Shopify theme's failure to fire Google Analytics 4 ecommerce events

    Posted by Grayson on 3 November 2022 at 8:57 am

    “Hey there, I’ve been fiddling around with Google Analytics 4 and started dabbling with our Shopify store. I added an ecommerce dataLayer push in a liquid file in the Sections folder, but for some reason, the dataLayer isn’t updating. I’m attempting a basic ‘view_item’ event, scanning religiously for typos. So just to troubleshoot, I swapped our ecommerce dataLayer push with a ‘test_event’ containing some nonsense data, and voila – it fired. Why isn’t Shopify playing nice with my eCommerce push to the dataLayer? Here’s what my code looks like…”

    Rishi replied 11 months, 2 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Oliver

    Member
    16 January 2023 at 10:53 am

    Hey, so looking at your code I spotted this bit:

    dataLayer.push({ ecommerce: null });
    

    The issue here is that the word “null” is actually making the dataLayer not work. Think of “null” like a giant off switch. By including it, you’re essentially pressing pause on all things dataLayer. What you should do is take out that line and it should be functioning properly then.

  • Rishi

    Member
    7 June 2023 at 3:09 pm

    It seems like your issue could be related to the syntax in your code. The liquid variables, which output strings, should be enclosed in quotes. Additionally, consider adding conditional statements to prevent certain name-value pair from appearing when they have no values. An example of how you could adjust your code to this effect has been provided. The code shows the incorporation of quotation marks on certain variables and conditional statements to prevent the appearance of name-value pairs without values. Also note the ‘ecommerce: null’ statement before you push your ‘view_item’ event.

Log in to reply.