-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
example with-google-tag-manager #20042
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
buildDuration | 8.5s | 8.5s | |
nodeModulesSize | 82.5 MB | 82.5 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.044 | 2.041 | 0 |
/ avg req/sec | 1222.89 | 1224.82 | +1.93 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.103 | 1.073 | -0.03 |
/error-in-render avg req/sec | 2266.12 | 2330.04 | +63.92 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-899eb31..d9d9.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
index.html gzip | 614 B | 614 B | ✓ |
link.html gzip | 621 B | 621 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
buildDuration | 10.2s | 10.2s | |
nodeModulesSize | 82.5 MB | 82.5 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
677f882d2ed8..34b9.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-899eb31..d9d9.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-01375..90b6.js gzip | 3.69 kB | 3.69 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..fd29.js gzip | 303 B | 303 B | ✓ |
withRouter-b..76ae.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Serverless bundles
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | ✓ |
link.js | 1.06 MB | 1.06 MB | ✓ |
routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
withRouter.js | 1.05 MB | 1.05 MB | ✓ |
Overall change | 5.16 MB | 5.16 MB | ✓ |
@lfades is there something more should I do in my PR, for it to be check? 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niko20 Hi there 👋 and thank you for the PR!
Added some minor changes and it now looks good to me. Thank you!
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
buildDuration | 11.4s | 11.3s | -63ms |
nodeModulesSize | 82.6 MB | 82.6 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.336 | 2.274 | -0.06 |
/ avg req/sec | 1070.11 | 1099.52 | +29.41 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.71 | 1.631 | -0.08 |
/error-in-render avg req/sec | 1462.28 | 1532.67 | +70.39 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
677f882d2ed8..5e70.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-e0d2962..b163.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-95c2..e870.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
polyfills-d3..23f6.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_app-0d19cb6..5497.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-85785..a9f3.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-42456f..0c06.js gzip | 887 B | 887 B | ✓ |
index-8081ce..e44f.js gzip | 227 B | 227 B | ✓ |
link-0ab9f83..fa00.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..c3d8.js gzip | 303 B | 303 B | ✓ |
withRouter-0..a68e.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.05 kB | 8.05 kB | ✓ |
Client Build Manifests
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_buildManifest.js gzip | 323 B | 323 B | ✓ |
Overall change | 323 B | 323 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
index.html gzip | 612 B | 612 B | ✓ |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 607 B | 607 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
buildDuration | 13.6s | 13.6s | |
nodeModulesSize | 82.6 MB | 82.6 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
677f882d2ed8..5e70.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-e0d2962..b163.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-95c2..e870.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
polyfills-d3..23f6.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_app-0d19cb6..5497.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-85785..a9f3.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-42456f..0c06.js gzip | 887 B | 887 B | ✓ |
index-8081ce..e44f.js gzip | 227 B | 227 B | ✓ |
link-0ab9f83..fa00.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..c3d8.js gzip | 303 B | 303 B | ✓ |
withRouter-0..a68e.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.05 kB | 8.05 kB | ✓ |
Client Build Manifests
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_buildManifest.js gzip | 323 B | 323 B | ✓ |
Overall change | 323 B | 323 B | ✓ |
Serverless bundles
vercel/next.js canary | niko20/next.js google-tag-manager-example | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | ✓ |
link.js | 1.06 MB | 1.06 MB | ✓ |
routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
withRouter.js | 1.05 MB | 1.05 MB | ✓ |
Overall change | 5.16 MB | 5.16 MB | ✓ |
@niko20 Thanks for the great example. I was wondering if a mistake was made regarding the
Shouldn't the above function pass the url to pageview? |
export const GTM_ID = process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID | ||
|
||
export const pageview = (url) => { | ||
window.dataLayer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.dataLayer
is not a method. Did you actually mean to use window.dataLayer.push
instead?
import * as gtm from '../lib/gtm' | ||
|
||
const handleRouteChange = () => { | ||
gtm.pageview() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url should be passed to this method call so it sets a page view correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the next/router docs, it looks like url is passed to handleRouteChange
Hi @camiblanch and @TriStarGod , yes, you’re right, I implement GTM in my ecommerce website, maybe when I passed my code to nextJs example , I missing something, I’ll check and modify , thanks for yours comments |
Hi ✌️
I've seen that many people have problem with implement Google Tag Manager, I've created an example of how insert "Google Tag Manager" in a NextJs app