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.

