Skip to content

feat(analytics): add the Google Ads conversion tag to the gtag loader - #7466

Merged
waleedlatif1 merged 2 commits into
stagingfrom
feat/google-ads-conversion-tag
Sep 4, 2026
Merged

feat(analytics): add the Google Ads conversion tag to the gtag loader#7466
waleedlatif1 merged 2 commits into
stagingfrom
feat/google-ads-conversion-tag

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Add the Google Ads conversion tag (AW-17916292239) site-wide, so it renders on every hosted route rather than a hand-maintained page list — partial coverage breaks gclid capture between the ad landing page and the conversion page
  • Configure it as a second config destination on the existing GA4 gtag.js loader instead of adding a second gtag/js script. That's Google's documented pattern for sending one page to multiple Google products, and a second loader would re-run the library and collide on the gtag element id that c15t derives from the vendor name
  • Allow the origins the Ads tag actually reaches in CSP: googleadservices + googleads.g.doubleclick.net in script-src, googleadservices in connect-src, and td.doubleclick.net + googleadservices in frame-src (the conversion linker writes its cookie from a hidden iframe). Without these the tag loads and its pings are silently blocked

Consent behavior is unchanged in shape. The tag rides the existing consent-managed loader, where Consent Mode v2 already maps ad_storage, ad_user_data, and ad_personalization to the marketing category — so someone who accepts measurement but declines marketing gets a cookieless ping, not conversion tracking. No new consent category, no unconditional script.

SPA page views are unaffected: GoogleAnalyticsPageViewTracker sends with send_to pinned to the GA4 id, so route changes don't fan out to the Ads destination.

This installs the tag only. Firing a conversion on signup or demo-booked still needs a send_to: AW-17916292239/<label> event with a label from the Ads UI.

Type of Change

  • New feature

Testing

Tested manually. bun run type-check clean; bun run lint, bun run check:audits (45 audits), block-registry check, and docs-manifest:check all pass. Added a unit test asserting both IDs configure on the single loader and that no second gtag/js src is registered — verified it fails when the config line is removed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Adds AW-17916292239 as a second `config` destination on the existing GA4
gtag.js loader rather than a second `gtag/js` script tag, which is Google's
documented pattern for sending one page to multiple Google products. It
loads on every hosted route through GLOBAL_CONSENT_SCRIPTS, so conversion
attribution is not split across a partial page set.

Consent is unchanged in shape: Consent Mode v2 already maps ad_storage,
ad_user_data, and ad_personalization to the `marketing` category, so a
visitor who accepts measurement but declines marketing gets a cookieless
ping instead of conversion tracking.

Also allows the googleadservices/doubleclick origins the Ads tag reaches in
script-src, connect-src, and frame-src; without them the tag would load and
its conversion pings would be silently blocked.
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 4, 2026 12:41am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a Google Ads destination to the existing consent-managed Google tag loader and extends the hosted CSP to permit the required Ads endpoints.

  • Configures the Google Ads ID through the existing GA4 loader.
  • Tests that both destinations are configured without registering a second loader.
  • Allows the required script, connection, and frame origins only in hosted deployments.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/consent/scripts.ts Adds the Google Ads destination to the existing consent-managed gtag initialization.
apps/sim/lib/consent/scripts.test.ts Verifies that GA4 and Google Ads share one gtag loader.
apps/sim/lib/core/security/csp.ts Adds the required Google Ads origins and correctly gates all new permissions to hosted deployments.

Reviews (2): Last reviewed commit: "fix(csp): gate the Google Ads frame orig..." | Re-trigger Greptile

Comment thread apps/sim/lib/core/security/csp.ts
Comment thread apps/sim/lib/core/security/csp.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

The script-src and connect-src entries for the Ads tag were already inside
the hosted-only branch, but the frame-src ones were not. The consent
provider that loads the tag never mounts off hosted, so a self-hosted or
dev deployment was permitting frames it can never use.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 850d1f0 into staging Sep 4, 2026
31 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/google-ads-conversion-tag branch September 4, 2026 00:48
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.

1 participant