Repository navigation
feat(traffic): turn conversions on in brand settings, with what to install and the Shopify pixel (CE-017, part 3) - #1529
Conversation
… Traffic snippet, for brands with conversions on (CE-017, part 1: server) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rder id sent first by anyone can't shut the real one out; keep no label or order ref that looks personal; check an event before reading the brand (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ippet, with consent first: journey pages, forms, ansvisor('conversion'), Consent Mode (CE-017, part 2)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent Mode default, read Consent Mode before keeping anything, take an id kept earlier as consent given, send only values the server takes, count a form once a page (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e after t.js, pause on a denying default even beside regional ones, and take a queued "denied" before keeping or sending anything (consent review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…onsent call, forms, calls and the Shopify pixel to install (CE-017, part 3) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ify's cookie banner's answer to the snippet, keep the pixel's amount and units in the server's range, and say what the snippet really does (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Needs changes.
What I checked:
- Without conversions.
- The Tracking card and the Traffic page's banner and dialog show the same tag as before, byte for byte (
trackingSnippetTag(…, null), tested). - The new card shows only its checkbox.
- The brand's new columns come in through
select('*')inmapBrandRow.
- The Tracking card and the Traffic page's banner and dialog show the same tag as before, byte for byte (
- Who changes it.
- The checkbox and the consent select are disabled for anyone who can't manage.
updateBrandwrites through RLS, whose update policy is admins and managers only.- An unknown consent mode is refused here and by 00286's check. A failed save turns the control back.
- The tag.
- The queue stub goes above the deferred tag, so a banner's or a thank-you page's earlier call is queued and replayed by
t.js. - The Select has
items, and the strings are inen.json.
- The queue stub goes above the deferred tag, so a banner's or a thank-you page's earlier call is queued and replayed by
- Turning it off. The toast and the help say the tag without conversions must go back on the site, and the Tracking card then shows that tag.
- The Shopify pixel.
- It sends only for a visitor the snippet kept on the storefront, so only after consent there, and it runs under Permission: Analytics.
- The address goes as
/checkout. Value and units go only within the server's ranges, and the server checks the currency again. - The consent script passes Shopify's answer both ways (
visitorConsentCollected) and reads it again on each page.
- Before the API deploy.
- The old
t.jsignoresdata-c: it keeps nothing and sends what it did before. - The old
/trackanswers the pixel's body with 204 and stores nothing, since the body has nos. - A brand can turn conversions on and install the tag, but nothing is kept or stored until the API is deployed. No live feature changes.
- The old
- Merge. Linear on #1528, no merge commits.
Before merge:
web/src/lib/conversion-tracking.ts:41-42,_conversions-card.tsx:216-224,en.json:7966-7967: the consent step gives onlyansvisor('consent', 'granted'), "once the visitor agrees, and on every page after".- The snippet takes an id kept earlier as consent on later pages (#1528).
- So on a site set up as the card says, a visitor who takes consent back in the banner is still followed until the 30 days run out. Nothing tells the snippet.
- Show
ansvisor('consent', 'denied');beside it, "when the visitor says no or takes consent back", and say the GTM tag needs both. - Show the step with
alwaystoo, without the granted line: a site whose own banner covers it still has visitors who refuse.
conversion-tracking.ts:111: without an order id, the pixel sendscheckout.tokenas the order ref.- That token is why the address goes as
/checkout(:79-80,:105): the thank-you page's path carries it. - 00286 keeps
order_reffor the order's own id at the shop. - Send no ref without an order id. Such an order then just isn't deduplicated.
- Change the test "names the order by its token without an id".
- That token is why the address goes as
Follow-ups:
3. en.json:7960: "or privacy policy". Where consent is needed, a privacy policy isn't consent to analytics storage. Say "Use this only if your cookie banner already asks for analytics storage, or where no consent is needed."
4. The pixel and the consent script are tested with stand-ins only. Before brands are pointed at them, try them once on a Shopify development store:
- the pixel reading the storefront's
ansvisor_vat checkout throughbrowser.localStorage; - the fetch from the pixel's sandbox;
loadFeaturesandvisitorConsentCollectedin a theme.
…id and one tracking code can store, keep an order's id only as a hash, and drop an index nothing reads (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…itor takes back, run queued consent calls first, add no hooks for a visitor it doesn't follow, and never stop the site's own push or route change (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nversion-settings
… "Don't wait" too; send no order ref without Shopify's order id, never the checkout token; say a privacy policy isn't consent (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… journey's reads compare keys instead of working each address out again (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nversion-settings
…se that ran 00286 before them, and keep a handle such as /@acme in a path: only an email goes (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'s part fails, and test the push wrapper with a send that fails (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nversion-settings
…hows the consent call too (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, both are in, plus follow-up 3 (08c24cf).
Also: in Wait mode, the refusal sits under its own "When the visitor refuses" line, below the grant. Item 4 (a Shopify development store) isn't something I can do from here. I've noted it as owed before brands are pointed at the pixel. Web: |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- Earlier items.
- Done (54bbb5b, 08c24cf).
DENY_CALL(web/src/lib/conversion-tracking.ts:49) shows in both modes (_conversions-card.tsx:218-231).- With Wait, it sits under its own "When the visitor refuses" line, below the grant.
- With Don't wait, the step is the refusal only, under that title.
denyHelpsays when to call it and what it does, and that matches #1528'sdeny().- The GTM line now asks for a tag for each line.
- Tests cover both modes' codes and titles.
- Done.
- The pixel sends
refonly with Shopify's order id (conversion-tracking.ts:119-120). - The test checks that the body has no
refand no token anywhere. The comment says why.
- The pixel sends
- Done (
en.json:7961). - Open, and noted by Cihan as owed: a run on a Shopify development store. It's kept below.
- Done (54bbb5b, 08c24cf).
- No regressions.
- The two commits touch only the card and its test,
conversion-tracking.tsand its test, anden.json. - Without conversions, the tags are as before.
- The Shopify consent script is unchanged and still shows with Wait only.
- The two commits touch only the card and its test,
- Merges. fdfd09d, e517de2 and db54491 only merge their parents (re-merged with
merge-tree: the trees match). The PR merges on main with a conflict only inschema.sql. CI passes at 08c24cf. - Before the API deploy. Same as round 30.
- The old
t.jsignoresdata-c. - The refusal call waits in the queue stub like the grant, and does nothing until the new
t.jsruns. - The pixel's post stores nothing.
- No live feature changes.
- The old
Follow-ups:
en.json:7969(denyHelp): with Don't wait, one refusal call doesn't last beyond the page it's made on.- A visitor who refused and later comes back from an AI answer gets a new id, kept as soon as the page loads (
tracking-script.js:152,:173in #1528). - They're then followed for 30 days, unless the site calls the refusal on that page too.
- Add "and on every page after, while they say no", as
consentHelpdoes for the grant. Under Wait the extra calls do no harm: nothing is kept without a grant.
- A visitor who refused and later comes back from an AI answer gets a new id, kept as soon as the page loads (
- Still owed from round 30: before brands are pointed at the pixel, run it once on a Shopify development store:
- the pixel reading
ansvisor_vthroughbrowser.localStorageat checkout; - the fetch from the pixel's sandbox;
loadFeaturesandvisitorConsentCollectedin a theme.
- the pixel reading
…ersion-events # Conflicts: # supabase/schema.sql
…nversion-settings
|
Merged the PR below it forward (5d3db9c), which brings in Checks after the merge:
|
…irst, so a long address reads fast and an encoded dot is caught (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or says no (review follow-up) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nversion-settings
…ush review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nversion-settings
|
Follow-up 1 is done (ee40a8e): Follow-up 2, the Shopify development store run, is still owed: it needs a store, so it's yours. The pixel isn't pointed at by any brand until then. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- Earlier items.
- Done (3d79c0a, c67caab).
denyHelp(web/messages/en.json:8008) now adds "and on every page after, while they say no", the wayconsentHelp(:8006) does for the grant.- The rest of the line matches #1528's
deny()(tracking-script.js:143): the stored id is deleted, what waited is dropped, and nothing is sent from that page until a grant. - With Don't wait, repeating the call is what stops a returning AI visitor's new id from being kept at load (
:152,:173). - With Wait, the card shows the same line. The extra calls do no harm, because nothing is kept without a grant.
- The rest of the line matches #1528's
- Still owed, as Cihan notes: the run on a Shopify development store. It stays below.
- Done (3d79c0a, c67caab).
- Merges. 5d3db9c, 0f1e974 and ee40a8e only merge #1528 forward.
- Before the API deploy. Same as round 31:
- The card goes live with the merge.
- The old
t.jsignoresdata-c, and the calls wait in the queue stub. - No live feature changes. The new words are text only.
Follow-ups:
- Still owed from round 30: before brands are pointed at the pixel, run it once on a Shopify development store. Check:
- that the pixel reads
ansvisor_vthroughbrowser.localStorageat checkout; - that the fetch works from the pixel's sandbox;
- that
loadFeaturesandvisitorConsentCollectedwork in a theme.
- that the pixel reads
Summary
CE-017, part 3: brand settings and the Shopify pixel. Stacked on #1528 (the snippet), which is on #1527 (server). The PR's own changes are its commits after #1528's branch.
The plan had the Shopify pixel and the Settings section as two PRs. The pixel's code is built in the web app, as the snippet's tag always was, from the public API URL and the brand's tracking code, so it ships with the Settings section that shows it. Five CE-017 PRs instead of six.
Brand settings › Tracking › Conversions from AI visits (new card, under the existing tracking card):
data-c="1" data-consent="…"), with the queue stub on the line above it. The tag is deferred, so a cookie banner's or a thank-you page'sansvisor(…)call always runs first; without the stub it would throw and be lost;ansvisor('consent', 'granted')) and a note on Google Consent Mode, including that a banner set up inside GTM needs a tag that runs the call;data-ansvisor-goal="demo"names a goal, anddata-ansvisor="off"leaves a form out;visitorConsentCollected, andanalyticsProcessingAllowed()on each page). Without it, the default mode would never keep an id on a Shopify store;The Shopify pixel (
shopifyPixelCode): oncheckout_completedit sends the order, its value, currency, units and the order id (the checkout's token only where Shopify gives none). An amount or units the server wouldn't take are left out, so the order still counts. It reads the visitor id the snippet kept on the storefront (the checkout is on the shop's domain) and sends to/track/:codeas the snippet's events do (#1527). A visitor the snippet didn't follow sends nothing. The checkout's address goes as/checkout, because the thank-you page's path carries the order's token.One tag everywhere: the existing tracking card and the Traffic page's snippet banner and dialog build the tag with
trackingSnippetTag. A brand with conversions on is never shown the old tag to copy.BrandgetsconversionsEnabled/conversionsConsent,updateBrandtakes them (an unknown consent mode is refused), andtypes/supabase.tshas the columns from 00286.Related issue
Content Editor spec v2, CE-017 (§7b points 31, 32, 35).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
data-c="1" data-consent="wait". The steps show the consent call, forms, calls and the queue stub.data-consent="always"and the consent step goes.I checked it in the browser at 1024 px, light and dark, on the demo brand: the tag, steps, Shopify pixel and limits. The setting was turned off again afterwards.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors; the 6 warnings are in files this PR doesn't touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Web:
yarn testandyarn build. Tests:analytics,browser.localStorage,fetch), checking its payload, a visitor not followed, a missing amount and the token fallback;updateBrand's new fields, and the Traffic dialog's tag.A pre-push review ran; its fixes are the last commit:
After them: lint, typecheck,
yarn testandyarn buildagain.🤖 Generated with Claude Code