Feat: Added Google Tag Manager to CheerpJ docs. - #436
Conversation
Deploying labs-browserpod-previews with
|
| Latest commit: |
85b1b6f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3824ca1f.labs-browserpod-previews.pages.dev |
| Branch Preview URL: | https://cheerpj-added-docs-gtm.labs-browserpod-previews.pages.dev |
|
Passes Linter and Prettier. |
|
@GabrielaReyna just a note about <pnpm-workspace.yaml>, it's added the following: This may have just been to ensure it passes local build. But let me know if it needs to be removed and I'll take it out. |
codingfrog27
left a comment
There was a problem hiding this comment.
Hi Liam! Overall looks good, nice to have the clunky hardcoded product check removed :)
Testing done
- checked pages and confirmed they had the container tag
- checked that browserpod pages kept its own tag
Requested changes
-
Like you already mentioned in your comment I think we should indeed get rid of the lines in the yaml file. They could break the build in the future.
-
Also since basehead should always be a subcomponent of shell, we can actually just pass the value from shell into basehead, and we don't have to define it twice. Not a big issue but thought this way would be more streamlined, and less prone to bugs (since before you get the id out of potentially different urls), I've requested changes for this.
Extra checks
- I assume we have the container itself live and published from the webUI right? if you're not getting data yet that's the first thing I'd double check
- I noticed we don't have anything for consent management, think it's the same for browserpod and depending on what you want the gtm for it's also not needed, just thought i'd flag it.
- Be aware that this only adds tracking to the CJ docs and not the CJ site itself
| allowBuilds: | ||
| esbuild: set this to true or false | ||
| sharp: set this to true or false | ||
|
|
There was a problem hiding this comment.
| allowBuilds: | |
| esbuild: set this to true or false | |
| sharp: set this to true or false |
Like you mentioned this should be removed. I think local build should pass without it as well and it'll cause the build to fail if we ever update to pnpm 11.
| import { SITE_TITLE } from "../consts"; | ||
| import companyFavicon from "../assets/branding/company/tower.svg"; | ||
| import { productFromUrl } from "../lib/products"; | ||
| import { gtmContainerId } from "../lib/gtm"; |
There was a problem hiding this comment.
| import { gtmContainerId } from "../lib/gtm"; |
only needs to be imorted in shell.astro with new setup
| title: string; | ||
| description: string; | ||
| image?: string | undefined; | ||
| } |
There was a problem hiding this comment.
| gtmId?: string | undefined; | |
| } |
add id as optional prop that can be passed from parent (which in our case will always be passed by shell)
| const { | ||
| title, | ||
| description, | ||
| image = product?.ogImage ?? "/social/common@2x.png", |
There was a problem hiding this comment.
| image = product?.ogImage ?? "/social/common@2x.png", | |
| gtmId, |
add it to props object
|
|
||
| const localised = getLocalisedPaths(Astro.url.pathname, Astro.currentLocale); | ||
|
|
||
| const gtmId = gtmContainerId(product); |
There was a problem hiding this comment.
| const gtmId = gtmContainerId(product); |
can be removed now since we inherit it from shell
| <BaseHead | ||
| title={title || SITE_TITLE} | ||
| description={description || SITE_DESCRIPTION} | ||
| {image} |
There was a problem hiding this comment.
| {image} | |
| {gtmId} |
we're passing the id to basehead here
This pull requests adds the Google Tag Manager tag to the CheerpJ Docs site, so that it will correctly feed analytics data into the CheerpJ GA4 property.
I've included Claude's comment below so you've got sight of its summary: