partytown icon indicating copy to clipboard operation
partytown copied to clipboard

[🐞] Google Analytics Events aren't fired

Open mrxbox98 opened this issue 8 months ago • 8 comments

Describe the bug

After setting up Google Analytics with Partytown (user analytics are working) events such as a purchase are not pushed to google analytics.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-heabie?file=src%2Froutes%2F%2Blayout.svelte

Steps to reproduce

Setup google analytics with partytown properly. Push an event like

window.gtag("event", "purchase", {
		DATA
	});

Browser Info

All

Additional Information

When not using Partytown the events are properly pushed.

mrxbox98 avatar Dec 26 '23 01:12 mrxbox98

I see, thanks for your report. Can you create a PR with a failing test for this issue? A vanilla JS one will be perfect.

gioboa avatar Dec 26 '23 10:12 gioboa

Did you use forwarding-events API ?

gioboa avatar Dec 26 '23 17:12 gioboa

Did you use forwarding-events API ?

Yes

<script>
        // Forward the necessary functions to the web worker layer
        partytown = {
            forward: ['dataLayer.push', 'gtag'],
        };
    </script>

mrxbox98 avatar Dec 26 '23 18:12 mrxbox98

A specific test for this issue will be awesome to solve this problem

gioboa avatar Dec 26 '23 18:12 gioboa

Did you proxy the url to resolve CORS?

lknlknim avatar Dec 26 '23 20:12 lknlknim

A specific test for this issue will be awesome to solve this problem

Not entirely sure how to write a test for it since I'm unfamiliar with this repo. https://stackblitz.com/edit/sveltejs-kit-template-default-heabie?file=src%2Froutes%2F%2Blayout.svelte should mostly replicate it.

Did you proxy the url to resolve CORS?

Everything else google analytics works so I don't think its CORS

mrxbox98 avatar Dec 27 '23 01:12 mrxbox98

Update: I just received an event in Google Analytics with this config so it might be something else that I have configured incorrectly. I'll give it a week to see what happens.

mrxbox98 avatar Dec 27 '23 05:12 mrxbox98

GA doesn't update data in real-time You can have more info here

gioboa avatar Dec 27 '23 09:12 gioboa