Learn business growth with Google Analytics 4 Forums Google Analytics 4 Enabling GA4 event tracking in apps-script: A step-by-step guide Reply To: Enabling GA4 event tracking in apps-script: A step-by-step guide

  • Mia

    Member
    20 January 2023 at 9:18 pm

    Hey there, looks like you didn’t define the dataLayer because it’s commented out, and I also see the gtag library isn’t loaded. Hmmm, isn’t app script executed in Node? Not too sure gtag.js plays well with Node. If it does, I’m still thinking we’d have issues with various dimensions.

    You could try the [measurement protocol](https://developers.google.com/analytics/devguides/collection/protocol/ga4) which I think is a better fit for the backend. There’s a [npm package](https://www.npmjs.com/package/ga4-mp) for it. Not sure if npm works in app script though.

    Or give [server-side GTM](https://developers.google.com/tag-platform/tag-manager/server-side) a go. Its default publishing kind of implies an app script as well, but it might prefer its own app script instance rather than sharing it with yours. Keep trying and let’s crack this.