partytown
partytown copied to clipboard
[🐞] After integration Partytown the GA4 statistics have decreased and worsened
Describe the bug
After integration, GA4 shows less traffic than the of data from Google Search Console and the quality of that traffic is low. For example, we see negative impact for:
- Bounce rate (from 40 to 75%).;
- Session duration - now is 0s;
- Visits;
Reproduction
Steps to reproduce
Partytown integration on projects:
Inside <head>:
<script type="text/partytown" src="https://www.googletagmanager.com/gtag/js?id=ID"></script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'ID');
</script>
Inside <body>:
<script >
window.partytown = {
forward: ['dataLayer.push'],
lib: ['/local/client_redesign/public/~partytown/']
};
</script>
<script>
Inline ~partytown/partytown.js
</script>
vite.config.js:
import { partytownVite } from '@builder.io/partytown/utils';
export default defineConfig({
...
plugins: [
partytownVite({
dest: join(__dirname, 'public', '~partytown'),
}),
]
});
Browser Info
Chrome, Safari, Firefox
Additional Information
Also we have Yandex Metrics scripts inside gtag and see same probleme there. It is worth noting that with Partytown the Yandex Metrics scripts assume that users have cookies disabled. This may be causing data corruption
This is what we saw as well. GA wasn't completely dead but we saw a massive drop in reporting when it went live.
You might want to read this comment: https://github.com/BuilderIO/partytown/issues/382#issuecomment-1667675238, specifically:
gtag needs to be a function expression (not declaration) on the window object
Any updates on this? Implemented https://github.com/BuilderIO/partytown/issues/476#issuecomment-1793026826 but we still see a drop in our analytics. We don't have currently async on our GTM script (same as the docs), maybe it affects it?
In our case it looks like GA stops sending the collect?v=
measurement requests when running in partytown. With the script in a separate partytown script tag it sends one measurement request and then stops, not sending any other information.