Handling Stripped UTM Parameters in Drupal on Pantheon
Marco Bouwer of The Savvy Few explains how to handle Pantheon’s automatic stripping of "utm_"
query parameters, which replaces their values with "PANTHEON_STRIPPED" to optimize caching performance. Since these stripped values are inaccessible via PHP, Marco outlines a JavaScript-based solution for retrieving and storing them within a Drupal webform submission.
The approach involves adding hidden fields in the webform for utm_source
, utm_medium
, and utm_campaign
and using a custom JavaScript library, crmleads.js, to pre-fill these fields by extracting values from the URL. A helper function ensures basic XSS prevention, while a Drupal library definition file, crmleads.libraries.yml
, loads the script. Additionally, the implementation of hook_webform_submission_form_alter()
allows the JavaScript to conditionally load for relevant CRM webforms.
This method ensures that marketing-related UTM parameters can be captured and utilized within a Drupal application without affecting Pantheon’s caching mechanisms.
Source Reference
Image Attribution Disclaimer: At The Drop Times (TDT), we are committed to properly crediting photographers whose images appear in our content. Many of the images we use come from event organizers, interviewees, or publicly shared galleries under CC BY-SA licenses. However, some images may come from personal collections where metadata is lost, making proper attribution challenging.
Our purpose in using these images is to highlight Drupal, its events, and its contributors—not for commercial gain. If you recognize an image on our platform that is uncredited or incorrectly attributed, we encourage you to reach out to us at #thedroptimes channel on Drupal Slack.
We value the work of visual storytellers and appreciate your help in ensuring fair attribution. Thank you for supporting open-source collaboration!