partytown icon indicating copy to clipboard operation
partytown copied to clipboard

[🐞] After integration Partytown the GA4 statistics have decreased and worsened

Open katyazanina opened this issue 1 year ago • 5 comments

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; pasted image 0

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

katyazanina avatar Oct 06 '23 11:10 katyazanina

This is what we saw as well. GA wasn't completely dead but we saw a massive drop in reporting when it went live.

samparmenter avatar Oct 24 '23 14:10 samparmenter

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

saurori avatar Nov 03 '23 20:11 saurori

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?

naveDavidMoovit avatar Apr 04 '24 08:04 naveDavidMoovit

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.

lampask avatar Apr 04 '24 10:04 lampask