Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] page_view and on_load events are not firing in GA4 #599

Open
harshkc opened this issue Jun 6, 2024 · 1 comment
Open

[🐞] page_view and on_load events are not firing in GA4 #599

harshkc opened this issue Jun 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@harshkc
Copy link

harshkc commented Jun 6, 2024

Describe the bug

I was trying to integrate partytown on redBus app and the collect calls are fired consistently but the page_view and onLoad events are not fired as soon as the page load which is fired in case of partytown not enabled, I am not able to see those calls in the network tab.(dataLayer.push is happening for these events)

My integration looks like this:

<script type="text/javascript">
                partytown = {
                    forward: ["dataLayer.push","gtag"],
                    lib: "/activities/public/scripts/~partytown/",
                    resolveSendBeaconRequestParameters: function (url) {
                        return url.hostname.includes('analytics.google') ||
                            url.hostname.includes('google-analytics')
                            ? { keepalive: 0 }
                            : {};
                        },
                };
            </script>
    
            <script async type="module" src="/activities/public/scripts/~partytown/partytown.js"/></script>

            <script type="text/partytown">
                (function() {
                    window.global = document;
                })();
                (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer',myTag);
            </script>

The gtag is not reaching the below method call when partytown is enabled
Screenshot 2024-06-06 at 5 51 29 PM

Does anyone have solution related to page_view events?

Reproduction

https://www.redbus.sg/things-to-do/

Steps to reproduce

  1. Integrate partytown
<script type="text/javascript">
                partytown = {
                    forward: ["dataLayer.push","gtag"],
                    lib: "/activities/public/scripts/~partytown/",
                    resolveSendBeaconRequestParameters: function (url) {
                        return url.hostname.includes('analytics.google') ||
                            url.hostname.includes('google-analytics')
                            ? { keepalive: 0 }
                            : {};
                        },
                };
            </script>
    
            <script async type="module" src="/activities/public/scripts/~partytown/partytown.js"/></script>

            <script type="text/partytown">
                (function() {
                    window.global = document;
                })();
                (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer',myTag);
            </script>
  1. Run the app and check if load events or page_view events are fired

Browser Info

Chrome

Additional Information

  1. The gtag and gtm js file is exact same and page_view event in both the cases are captured within the script, only issue is sendBeacon function call never happens in the case of partytown.
  2. Partytown has the highest priority and it loads at the earliest
  3. Gtag is fired from gtm script that is cached by service worker. Thus, no cases of delayed loading can happen.
@harshkc harshkc added the bug Something isn't working label Jun 6, 2024
@dsacramone
Copy link

Describe the bug

I was trying to integrate partytown on redBus app and the collect calls are fired consistently but the page_view and onLoad events are not fired as soon as the page load which is fired in case of partytown not enabled, I am not able to see those calls in the network tab.(dataLayer.push is happening for these events)

Hey, did you resolve this, if so - show?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants