Skip to content

feat(shopify): Start the app pixel only on checkout pages - #5374

Open
BeltranBulbarellaDD wants to merge 2 commits into
beltran.bulbarella/shopify-session-activityfrom
beltran.bulbarella/shopify-app-pixel-checkout-only
Open

BeltranBulbarellaDD wants to merge 2 commits into
beltran.bulbarella/shopify-session-activityfrom
beltran.bulbarella/shopify-app-pixel-checkout-only

Conversation

@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor

Motivation

Shopify runs the app Web Pixel on every page, including the storefront pages where the theme app embed already runs the storefront SDK. On those pages the pixel started its own session manager and wrote the shared _dd_s_v2 cookie through browser.cookie, next to the storefront SDK. Two writers can create two session IDs when no session exists yet.

Stacked on #5370.

Refs: https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/7494435347/Deploying+the+Datadog+Shopify+app

Changes

browser-rum-shopify

  • shopifyAppPixelPlugin reads the page URL from the Web Pixel init context (api.init.context.document.location.href) when the pixel renders, and aborts the init outside checkout pages (CHECKOUT_PATH_PATTERN). The URL is available synchronously, so no page_viewed wait is needed.

e2e

  • New shopifyAppPixel.scenario.ts: runs on a dev store with the Datadog Shopify app installed (theme app embed + app Web Pixel). Flow: storefront → product → add to cart → checkout → click → back to the storefront. It checks the views and clicks on both surfaces, a single session, a single _dd_s_v2 cookie, and no "loaded more than once" / "already initialized" warning.
  • shopifySetup serves the local browser-rum-shopify build in place of the staging CDN deploy-feature bundle the store loads, and forwards the real intake requests (routed on the browser context, so the pixel worker's requests are included) to the test intake.
  • withShopifyApp() takes an optional store URL and password; the existing scenario keeps the custom-pixel-e2e store and its SSM password.
  • The title contains "shopify", so it is excluded from PR pipelines and runs in the scheduled e2e-shopify-scheduled job with the other Shopify test.
  • The worker e2e helper provides a checkout init context.

Note: the dev store URL and its storefront password are hardcoded in the scenario for now.

Test instructions

  • Unit: yarn test:unit packages/browser-rum-shopify (new test: init aborts outside checkout pages).
  • Worker e2e: yarn test:e2e -g "dedicated web worker" --project=chromium --project=firefox --project=webkit
  • App e2e (needs a fresh bundle): (cd packages/browser-rum-shopify && yarn build:bundle) && yarn test:e2e -g "shopify app tracks" --project=chromium

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Shopify also runs the app Web Pixel on storefront pages, where the
storefront SDK already collects the data and writes the session cookie.
Check the page URL from the Web Pixel init context when the pixel
renders, and abort the init outside checkout, so the storefront keeps a
single session cookie writer.
Run the storefront and checkout flow on a dev store with the Datadog
Shopify app installed, serving the local SDK build in place of the
staging CDN bundle and forwarding the real intake requests to the test
intake. Check that the storefront and checkout share one session and
one session cookie, and that the SDK is not loaded twice.

withShopifyApp() now accepts a store URL and password, and the
scheduled e2e-shopify-scheduled job runs the scenario with the other
Shopify test.
@BeltranBulbarellaDD
BeltranBulbarellaDD requested a review from a team as a code owner December 4, 2026 11:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T11:11:33.893140Z b4d1b85 PR opened
🔒 Security Review ✅ Completed 2026-12-04T11:16:31.821297Z b4d1b85 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 194.87 KiB 194.87 KiB 0 B 0.00% ✅
Rum 194.85 KiB 194.85 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.58 KiB 60.58 KiB 0 B 0.00% ✅
Rum Slim 150.24 KiB 150.24 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 228.82 KiB 228.89 KiB +68 B +0.03% ✅
Rum Shopify Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@datadog-official

datadog-official Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 66.67%
• Overall Coverage: 78.08% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b4d1b85 | Docs | View more details | Give us feedback!

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The checkout guard stops storefront app pixels before session-cookie setup, preventing them from competing with the theme embed as session writers. Checkout initialization remains reachable.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit b4d1b85

This branch has not been deployed

No deployments
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