Skip to content
Discussion options

You must be logged in to vote

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:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<ID>"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', <ID>);
</script>

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

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by heldtogether
Comment options

You must be logged in to vote
8 replies
@zeke-john
Comment options

@The-Professor99
Comment options

@tobiholic
Comment options

@valentinjurca
Comment options

@tobiholic
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
8 participants