WD-34696: Only send UTMs to Marketo for non-essential cookie consent#16216
WD-34696: Only send UTMs to Marketo for non-essential cookie consent#16216
Conversation
Check the _cookies_accepted cookie in marketo_submit() and only attach UTM values to the enrichment payload when the consent type is functionality, performance, or all. Essential and unset consent types will no longer have UTM data forwarded to Marketo. Includes a temporary dry_run query param for QA (to be removed before merge).
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure UTM parameters are only sent to Marketo when the user has consented to non-essential cookies, aligning Marketo enrichment behavior with cookie consent state.
Changes:
- Added consent detection via
_cookies_acceptedand gated attaching UTM fields to the enrichment payload. - Prevented parsing/attaching UTMs from the encoded
utmscookie/form field when consent isessential/unset. - Added a temporary
dry_run=truemode on/marketo/submitthat returns payloads as JSON (intended for QA only).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Only attach UTM values when the user has consented to | ||
| # non-essential cookies (functionality, performance, or all) | ||
| cookie_consent = flask.request.cookies.get("_cookies_accepted", "unset") | ||
| non_essential_consent = cookie_consent in { | ||
| "functionality", "performance", "all"} | ||
|
|
There was a problem hiding this comment.
This change introduces new consent-dependent behavior for what gets sent to Marketo, but there are no unit tests covering the /marketo/submit path. Since webapp/views.py already has view-level tests for related UTM helpers, add tests that assert UTMs are stripped when consent is essential/missing and preserved when consent is functionality/performance/all (including UTMs provided via hidden fields and via acquisition_url).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16216 +/- ##
==========================================
- Coverage 48.52% 48.36% -0.17%
==========================================
Files 37 37
Lines 5875 5891 +16
==========================================
- Hits 2851 2849 -2
- Misses 3024 3042 +18
🚀 New features to boost your workflow:
|
…hen consent is essential/unset
|
@Onibenjo looks like the links from the PR description are not working, however the demo is. So I'll replace the links with the updated links. |
|
@Onibenjo looks good! Just remember to remove the QA code. |
15c27ed to
036fed4
Compare
Done
functionality,performance, orall)essentialorunset(or cookie is missing), UTMs are stripped from the payload before it reaches Marketo?dry_run=truequery param on/marketo/submitfor QA — returns the payloads as JSON without calling the Marketo API. Remove before merge.QA
This can be tested entirely on the DEMO using
curl. The?dry_run=trueparam returns the Marketo payloads as JSON without making any API calls.Test 1:
essentialconsent — UTMs should NOT be sentExpected:
non_essential_consent: false, andenriched_payload.input[0].leadFormFieldsshould have noutm_sourceorutm_mediumkeys.Test 2:
performanceconsent — UTMs SHOULD be sentExpected:
non_essential_consent: true, andenriched_payload.input[0].leadFormFieldsshould containutm_source: "google"andutm_medium: "cpc".Test 3:
functionalityconsent — UTMs SHOULD be sentExpected:
non_essential_consent: true, UTM fields present in enriched payload.Test 4:
allconsent — UTMs SHOULD be sentExpected:
non_essential_consent: true, UTM fields present in enriched payload.Test 5: No
_cookies_acceptedcookie — UTMs should NOT be sentExpected:
cookie_consent: "unset",non_essential_consent: false, no UTM fields in enriched payload.Summary table
_cookies_acceptedessentialunset/ missingfunctionalityperformanceallBefore merge
dry_runblock fromwebapp/views.pyIssue / Card
Fixes https://warthogs.atlassian.net/browse/WD-34696
Help
QA steps - Commit guidelines