Search code examples
javascriptgoogle-tag-managergoogle-analytics-4

Purchase event going off 3 times in Google Tag Assistant


I'm managing a website that was created and is being hosted on Shoptet and I'm facing a problem that when I "preview" the tags in Google Tag Assistant, the purchase event is being fired 3 times instead of 1, never more, never less, and all of them have unique IDs and finally all 3 purchases are being sent to both GA4 and GAds and that's a problem. The event triggers when a "purchase" event occurs through DataLayer.

In-between the purchase events there are always the same 2 events. After the first purchase event there is "Set"; API Call: gtag("set", {currency: "CZK"}) event happening. After second purchase event there is "fbloaded"; API Call: dataLayer.push({fbpixel: "loaded", event: "fbloaded", gtm.uniqueEventId: 11}) event happening, the succession of the events can be seen in the picture: fired events.

From what I understand the "fbloaded" event has something to do with Facebook pixel and there is a Facebook account linked to the website to measure conversions. I had tried unlinking Facebook but the event still happened.

There is also an option to link a GA4 account to the website through admin page - the same as in Wordpress or in other platforms and I have that linked. I had tried unlinking that and in-return no events were tracked.

I have also checked multiple times if I don't have some "doubled" tags or some exceptions that would result in this behavior.

I also checked the full DataLayer code. In the first purchase event the code has the most lines, in the second it has less and finally in the last one there is the least amount of lines of code. I reached the conclusion that the last one doesn't have that many lines because of facebook and that it doesn't need that much information but I don't know whether that's correct or not.

I would like to know whether there is a way how to join these 3 events together or get rid of them or do something so that there is only one event being tracked and sent to GA4 and GAds?


Solution

  • Looks to me like you've done all the debugging properly on the analytics side. You're seeing three events because the dataLayer object has three events. So nothing's wrong with your setup on the analytics side. Seems like the mistake is on the CMS side.

    What's wrong is how you push events into the dataLayer. Only the first purchase event should be pushed. The rest are mistakes. Your conclusion about the size of the dataLayer objects is wrong. You don't need multiple DL objects to fire multiple tags. Facebook will be perfectly fine firing on the same DL purchase event as GA and maybe twenty other pixels.

    Seems like another reason for this behavior may be misusage of gtag versus GTM. You have to use either one. GTM abstracts the gtag usage from you. If you do both, you're interfering with what GTM does. What concerns me too is how you give your CMS the analytics id while also using GTM. If you use GTM, you should disable any other analytics in your CMS and do all the tracking in GTM, relying on the dataLayer.