Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Understanding the Functionality of the ecommerce Property in GTM Events › Reply To: Understanding the Functionality of the ecommerce Property in GTM Events
-
Actually, you’re right. The main difference between gtag.js and dataLayer has to do with flexibility and reusability. Using DataLayer is preferred because it’s a more flexible option, especially if you’re not only using Google Analytics, but also tools like Facebook Pixel or other third-party pixels.
All these tools share similar Ecommerce features like view_item, add_to_cart, purchase, etc. When you use DataLayer, you only need to populate the ‘items’ once, and you can reuse it for other pixels as needed.
Whereas with gtag.js, it’s more restricted – it will only apply the function to Google Analytics and Google Ads. So if you need to implement say, Facebook Pixel in the future, you’ll have to start all over from scratch.
Using Data Layer makes things much simpler, especially for websites with a complex tracking setup. Not only does it prevent redundancy, but it will make your life a lot easier in the long run. It’s all about planning and reducing future workload!