Skip to content

[AMPMKT-10009] feat(analytics): instrument docs with GTM and PostHog - #718

Open
dbarrialitebox wants to merge 12 commits into
amp-labs:mainfrom
dbarrialitebox:AMPMKT-10009_docs-gtm-baseline
Open

dbarrialitebox wants to merge 12 commits into
amp-labs:mainfrom
dbarrialitebox:AMPMKT-10009_docs-gtm-baseline

Conversation

@dbarrialitebox

@dbarrialitebox dbarrialitebox commented Sep 1, 2026

Copy link
Copy Markdown

Description

Docs is the only surface with no analytics of any kind, and it is not being
redesigned, so it gives a reference line the rebuilt pages cannot.

  • docs.json — enables GTM container GTM-KKG4NLZD, and adds ?trk=docs to
    the two navbar hrefs so docs can be attributed as a signup source.
  • analytics.js (new) — pushes login_button_clicked and cta_clicked to the
    dataLayer, and loads posthog-js. Mintlify includes any .js in the content
    directory on every page.
Element Event Properties
Sign in Login Button Clicked label · section: navbar · destination_url
Start building now CTA Clicked label · section: navbar · element_type: button · conversion_type: signup · destination_url

Two decisions worth knowing:

  • The container's tags read the dataLayer, not the DOM, and it does not load
    posthog-js — it assumes an instance is already on the page. Both gaps are what
    analytics.js fills.
  • Mintlify's native integrations.posthog is not used. It exposes only
    apiKey / apiHost / sessionRecording, so autocapture cannot be turned off.
    Docs sends two events and nothing else; before_send enforces it.

capture_pageview is off, so docs reports no traffic volume. The two events still
carry $pathname, so no report in the plan breaks.

Open question: consent

The marketing site starts PostHog opted out and waits for
cookieConsent.setConsent(). Docs has no equivalent and this PR adds none. Both
are on *.withampersand.com and share the cookie, so this is one posture, not two.
Needs a call from whoever owns the consent policy before merge.

Screenshot

N/A

@dbarrialitebox dbarrialitebox changed the title feat: AMPMKT-10009 Enable GTM on docs.withampersand.com feat: AMPMKT-10009 Instrument docs.withampersand.com (GTM + PostHog) Sep 1, 2026
@dbarrialitebox dbarrialitebox changed the title feat: AMPMKT-10009 Instrument docs.withampersand.com (GTM + PostHog) [AMPMKT-10009] feat(analytics): instrument docs with GTM and PostHog Sep 1, 2026
@dbarrialitebox
dbarrialitebox marked this pull request as ready for review September 1, 2026 20:42
@dionlow
dionlow requested a review from anushat05 September 2, 2026 22:19
Comment thread src/docs.json
"contextual": {
"options": [
"copy",
"view"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/docs.json is the main configuration file for the docs. Do not edit it manually, edit src/generate-docs.ts instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants