Converting Google Ads tag to Next Third Party sendGAEvent #62386
-
SummaryI'm trying to add Google Ads conversion tracking to my site. The tag they provide is:
And to fire the event:
Following the documentation (https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#sending-events), it seems like it's quite straightforward. In layout.tsx, I've got:
Then in page.tsx, I've got
Using Tag Assistant (https://tagassistant.google.com/), I can see that the data layer is initialised but there's no conversion event firing. I accept the possibility that I've done something wrong here, but it also seems like the docs might not be up to date. [EDIT: actually given the code above, the console gives the warning Any help would be appreciated. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
You are using Google Tag Manager so you have to change GoogleAnalytics to Then in layout.tsx You don't need this code:
As this is automatically added by nextjs, Then event using:
|
Beta Was this translation helpful? Give feedback.
-
Hi all! I know the answer has been provided to this issue already, but I am running in a similar problem and hope to find some help... In my layout file, I added:
When I run the google tag extension in chrome, I get the following information:
So I guess the googleTag is setup correctly in my app. In a dialog I created a form, where new users can sign up. If the sign up is successful, I want to fire the conversion:
But still I cannot change the conversion status to active. When I try to trigger the conversion action with the tag assistant, it always fails and the conversion is not detected. But the user is created successfully. I appreciate any tips or help, tried a lot already to get the conversion going.. Thanks all! |
Beta Was this translation helpful? Give feedback.
You are using Google Tag Manager so you have to change
GoogleAnalytics to
import { GoogleTagManager } from '@next/third-parties/google'
Then in layout.tsx
You don't need this code:
As this is automatically added by nextjs,
Then event using:
import { sendGTMEvent } from '@next/third-parties/google'
sendGTMEvent({ event: 'conversion', value: { 'send_to': '<ID>/<EVENT>' }})
I hope so this helps