This project is not covered by Drupal’s security advisory policy.
A recipe that shows Canvas Conditional Container in action. It adds a fundraising landing page built in Drupal Canvas, with an appeal section that appears only to visitors who arrive from a specific ad campaign.
Apply it to see how a content creator can tailor part of a page to campaign traffic, without writing code or leaving the Canvas editor.
What it adds
- A Canvas page, The Future is Yours to Give, at
/give. Everyone sees an intro, impact cards, a quote from a community partner, giving levels and a closing call to action. - An appeal section, The Need Has Never Been Greater, inside a Conditional container. It appears only when the URL includes
utm_campaign=never_greater. - A Context, UTM campaign: never_greater, that uses the Request param condition from Condition Query.
- The Use Contexts in conditional containers permission for the Content editor role, so editors can set up their own conditional sections.
Requirements
- A Drupal CMS site using the Haven site template. The page uses Haven's components, and the permission goes to its
content_editorrole. - Canvas Conditional Container
- Condition Query
- Context 5.x. Context 5 is a release candidate, so allow it in your site's
composer.json:composer require drupal/context:^5.0@RC
Installation
Canvas Conditional Container and this recipe are sandbox projects, so they aren't available through Composer yet.
- Clone Canvas Conditional Container into
web/modules/custom. - Run
composer require drupal/condition_query. - Clone this recipe into the
recipesfolder at your project root. - From the
webfolder, rundrush recipe ../recipes/canvas_conditional_container_example.
Trying it out
Compare these two URLs:
/give: the page without the appeal/give?utm_campaign=never_greater&utm_source=google&utm_medium=cpc: the appeal appears below the intro
Then open the page in Canvas and select the Conditional container to see its visibility rule. In the editor preview, the container always shows its content, with a badge summarizing its rules.
The Donate now buttons link to /donate, which Haven doesn't provide. Create a page there, or point the buttons at your donation platform.
Things to know
- Use lowercase campaign names. Condition Query lowercases the value in the Context but not the visitor's URL, so
utm_campaign=Never_Greaterwon't match. - It works on the landing page only. UTM parameters are only in the URL of the page the ad links to, so the appeal disappears if the visitor goes to another page.
- Check your CDN. Drupal's page cache stores each URL, query string included, separately, so this works with it. Many CDN and Varnish setups drop
utm_*parameters from the cache key. If yours does, exclude this page from that rule, or every visitor gets whichever version was cached first. - Google Ads auto-tagging adds
gclid, not UTM parameters. Addutm_campaign=never_greaterto the ad's final URL or tracking template. - The sample content is invented. The quote, names and giving amounts are placeholders. Replace them before publishing the page.
Related projects
- Canvas Conditional Container: the component this recipe demonstrates.
- Condition Query: provides the query parameter condition.
- Context: manages the Contexts that conditional containers use.
Project information
- Ecosystem: Canvas Conditional Container, Drupal Canvas
- Created by mandclu on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.


