Skip to content

attribution: carry session + campaign identity into shopify orders - #392

Draft
sshane wants to merge 1 commit into
masterfrom
posthog-attribution
Draft

attribution: carry session + campaign identity into shopify orders#392
sshane wants to merge 1 commit into
masterfrom
posthog-attribution

Conversation

@sshane

@sshane sshane commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The marketing site and the shop are different origins, so Shopify sees none of our attribution: landing_site is just the cart permalink (/cart/c/) and note_attributes is empty on all of the last 250 orders. mc_cid reaches comma.ai fine (1,921 pageviews in 30d) and now survives the harness rewrite, but nothing forwards it into the cart.

Capture each inbound touch to localStorage and write it into the cart, where it lands in order.note_attributes and can be queried from the Admin API alone.

  • first touch is frozen; last touch is overwritten ONLY on a real touch (tracking param or external referrer). A direct return must not clobber an earlier campaign touch -- 67% of buyers convert across more than one session and 33% take more than a day, so that case is the norm.
  • carts persist in localStorage across visits, so refresh attributes via cartAttributesUpdate at checkout rather than trusting cart-create time.
  • mc_eid identifies the person on an email click with no form submission; the signup form attaches the email. Both give cross-device stitching that device-local storage cannot.

Verified in a browser: campaign touch survives a direct return with no params and no referrer, and cartAttributes() emits distinct_id, session_id, mc_cid and both touch blobs.

Not included: the orders/create webhook that posts a purchase event back to PostHog. That closes the funnel and needs somewhere to run.

The marketing site and the shop are different origins, so Shopify sees
none of our attribution: landing_site is just the cart permalink
(/cart/c/<token>) and note_attributes is empty on all of the last 250
orders. mc_cid reaches comma.ai fine (1,921 pageviews in 30d) and now
survives the harness rewrite, but nothing forwards it into the cart.

Capture each inbound touch to localStorage and write it into the cart,
where it lands in order.note_attributes and can be queried from the
Admin API alone.

- first touch is frozen; last touch is overwritten ONLY on a real touch
  (tracking param or external referrer). A direct return must not clobber
  an earlier campaign touch -- 67% of buyers convert across more than one
  session and 33% take more than a day, so that case is the norm.
- carts persist in localStorage across visits, so refresh attributes via
  cartAttributesUpdate at checkout rather than trusting cart-create time.
- mc_eid identifies the person on an email click with no form submission;
  the signup form attaches the email. Both give cross-device stitching
  that device-local storage cannot.

Verified in a browser: campaign touch survives a direct return with no
params and no referrer, and cartAttributes() emits distinct_id, session_id,
mc_cid and both touch blobs.

Not included: the orders/create webhook that posts a purchase event back
to PostHog. That closes the funnel and needs somewhere to run.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

deployed preview: https://comma-web--pr392-qpaw773j.web.app

Welcome! Make sure to:

  • read the contributing guidelines
  • mark your PR as a draft until it's ready to review
  • post the preview on Discord; feedback from users will speedup the PR review

@sshane
sshane marked this pull request as draft September 9, 2026 23:41
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