The generated page without the campaign utm code
The generated page with the campaign utm code

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_editor role.
  • 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.

  1. Clone Canvas Conditional Container into web/modules/custom.
  2. Run composer require drupal/condition_query.
  3. Clone this recipe into the recipes folder at your project root.
  4. From the web folder, run drush 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_Greater won'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. Add utm_campaign=never_greater to 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

Project information

Releases