Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Simo Ahava or Google doc? Question on dataLayer.push({ ecommerce: null });

While setting up GTM I came across a crossroad and I don't know which option is best, and why.

Simo Ahava declares window.dataLayer before any snippet, and does not clear the ecommerce object

Screenshot of a snippet by Simo, using window.dataLayer and not clearing ecommerce object

On the other side, Google recommends clearing the ecommerce object before any ecommerce event to prevent any potential issues with variables using datalayer v1. The way google puts it is "to prevent multiple ecommerce events on a page from affecting each other"

Google clears ecommerce object and uses a different syntax

Google's method sounds better to me here, although Simo is arguably the most respected guy in the tracking space.

So which method is the best, and why?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I do not think these two snippets cover the same use cases. Simo talks about initializing the datalayer (usually before the GTM snippet, there would be little point in doing this afterwards), the second snippet assumes that the dataLayer object already exists.

So this is not "one or the other", but ideally you do both - setting up the dataLayer before the GTM snippet, but also clearing the e-commerce object between two unrelated e-commerce pushes.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!