Add "Enabled only with ?promoted=1" mode to marketing attribution field#1351
Open
slightlyoffbeat wants to merge 1 commit into
Open
Add "Enabled only with ?promoted=1" mode to marketing attribution field#1351slightlyoffbeat wants to merge 1 commit into
slightlyoffbeat wants to merge 1 commit into
Conversation
Converts FreeFormPage2026's enable_marketing_attribution boolean into a three-state marketing_attribution_mode CharField: - Disabled (default) - Enabled (always promoted) - Enabled only when ?promoted=1 in URL The new "param" mode lets a single landing page serve both organic and paid traffic — the promoted treatment (data-promoted-page attribute, marketing opt-out checkbox, consent banner allowlisting, stub attribution) only renders for visitors arriving via the ?promoted=1 query param. Organic visitors see a normal page without the "Share how you discovered Firefox" checkbox. When mode is "param" and the URL is missing the param, the page renders identically to "Disabled" — no data-promoted-page attribute, no marketing opt-out bundles, no checkbox HTML. No JS changes required; the existing isPromotedPage() / shouldShowCheckbox() infrastructure from PR #1189 continues to work via the data-promoted-page attribute. The legacy enable_marketing_attribution boolean is kept in PromotedPageMixin for one deploy cycle to avoid create-then-drop in the same PR (per wagtail-snippet skill guidance). A follow-up PR will remove it after this one is fully deployed. Migration 0086 adds the new field; 0087 data-migrates existing True values to "enabled" mode.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1351 +/- ##
=======================================
Coverage 79.99% 79.99%
=======================================
Files 149 149
Lines 9666 9678 +12
=======================================
+ Hits 7732 7742 +10
- Misses 1934 1936 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I should also note that I tucked in an addition of a skill that helps with snippet creation and modification |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts
FreeFormPage2026'senable_marketing_attributionboolean into a three-statemarketing_attribution_modeCharField:?promoted=1in URL — newThe "param" mode lets a single landing page serve both organic and paid traffic. The promoted treatment (
data-promoted-pageattribute, marketing opt-out checkbox, consent banner allowlisting, stub attribution) only renders for visitors arriving via?promoted=1. Organic visitors see a normal page without the "Share how you discovered Firefox" checkbox.Builds on PR #1189 (merged) — no JS changes; the existing
isPromotedPage()/shouldShowCheckbox()infrastructure continues to work via thedata-promoted-pageattribute.How it works
A new
is_promoted_page(request)method onPromotedPageMixindecides per-request whether to render the promoted treatment:?promoted=1data-promoted-pagenoindex"True""True"Rows 1 and 4 (Disabled / Param-without-param) render identical HTML — the mode value is preserved server-side but the rendered output is the same.
noindexdiffers by mode: only "Enabled (always)" gets it. "Param" mode keeps the base URL indexable for organic search (Googlebot crawls without query params, so it sees the organic version).Migration
Two migrations:
0086_freeformpage2026_marketing_attribution_mode_and_more.py— adds the newmarketing_attribution_modeCharField. Auto-generatedAlterFieldon the legacy boolean is a functional no-op (Django bookkeeping for removed help_text).0087_migrate_marketing_attribution.py— data-migrates rows whereenable_marketing_attribution=Truetomarketing_attribution_mode="enabled". Includesforwards/backwardsfor safe rollback.The legacy
enable_marketing_attributionboolean is kept in the model and DB for one deploy cycle. This avoids create-then-drop in the same PR — old pods running pre-merge code can still query the legacy column harmlessly during a rolling deploy. A follow-up PR will remove it after this one is fully deployed.Open questions
Wagtail revisions — old page revisions stored in
wagtailcore_revisionstill haveenable_marketing_attribution: truebut nomarketing_attribution_mode. If an editor reverts to a pre-merge revision, the restored page would havemarketing_attribution_mode=""(Disabled), losing the promoted setting. Acceptable risk, or worth a revision-migration script?Cache safety for
parammode — pages in "param" mode render different HTML for?promoted=1vs no param. The CDN cache key needs to vary by thepromotedquery string for these URLs (otherwise an organic visitor could see a cached promoted response or vice versa). Worth confirming the CDN config before merging.No new unit tests — the original
enable_marketing_attributionboolean shipped without unit tests, so I matched that pattern. Should we add tests foris_promoted_page()per-mode behavior and the data migration's forwards/backwards? Happy to add in this PR or a follow-up.Scope — only
FreeFormPage2026usesPromotedPageMixintoday. Other page types (HomePage,WhatsNewPage2026) don't. If MarTech wants promoted treatment on those too, that's a one-line model change per page type. Intentional to scope this PR to FreeFormPage2026 only?Display label wording — "Enabled only when ?promoted=1 in URL" is wordy in the dropdown. Open to suggestions like "Enabled with
?promoted=1param" or similar.Risks
Next steps
enable_marketing_attributionfromPromotedPageMixin, runmakemigrations cms, ship0088_remove_freeformpage2026_enable_marketing_attribution.py. Branch name suggestion:promoted-landing-on-param-cleanup.?promoted=1when pointing atmarketing_attribution_mode="param"pages.is_promoted_page()and the data migration (Q3 above).Test plan
pytest springfield/cms/(558 passed)npm run jasmine(470 specs, 0 failures)pre-commit run --all-filesclean (only the expected "untracked migrations" — now resolved)python manage.py makemigrations --check --dry-runexits cleanly?promoted=1combination (see plan file section "End-to-end manual tests")Related
data-promoted-pageattributePromotedPageMixinPR — added the boolean this PR is replacing