UTM parameters are one of the most effective ways to track marketing attribution across your Webflow website. But there's a common challenge: these valuable tracking parameters are lost when visitors navigate between pages.
Don't worry—this guide will show you exactly how to maintain UTM parameters across your entire site, no third-party tools required!
Before diving into the implementation, let's explore when this solution can help your marketing efforts. This UTM tracking implementation is particularly valuable when:
Some real world examples where UTM parameters can help you better track conversions are the following:
UTM parameters are special tags added to your URLs (after a question mark '?') that help track where your traffic comes from. For example, when you run a campaign with an influencer, you might use a URL like:
https://yoursite.com?utm_source=influencer&utm_medium=social&utm_campaign=spring_launch
When someone clicks this link, analytics tools like Google Analytics can track that this visit came from your influencer campaign.
☝🏻 However, here's where things get tricky: if the visitor clicks to another page on your site (like your contact page), these UTM parameters are typically lost. This means:
We'll cover two different methods to maintain UTM parameters across your Webflow site:
This method is perfect when you only need to track UTMs within a single visit. Here's the code you'll need:
<script>
/**
* UTM Parameter Pass-through Script for Webflow
* Automatically maintains UTM parameters across page navigation
* @author BRIX Templates
* @version 1.0.0
* @description Basic version - maintains UTMs only during the current session
*/
(function() {
// Wait for the page to fully load
window.addEventListener('load', function() {
// Get current URL parameters
var params = new URLSearchParams(window.location.search);
// Only proceed if we have parameters to work with
if (params.toString().length > 0) {
// Select all links on the page
var links = document.querySelectorAll('a[href]');
// Process each link
links.forEach(function(link) {
try {
// Create URL object from the link
var url = new URL(link.href);
// Add each UTM parameter to the link
params.forEach((value, key) => {
// This will either add or update existing UTM parameters
url.searchParams.set(key, value);
});
// Update the link with new URL including UTMs
link.href = url.toString();
} catch (error) {
console.warn('Error processing link:', link, error);
}
});
// Log confirmation message
console.log("BRIX Templates: UTM parameters successfully appended to " + links.length + " links");
}
});
})();
</script>
This script works by:
This approach provides more comprehensive tracking by storing UTM parameters in localStorage, allowing them to persist even after the user leaves your site. While this method offers better tracking capabilities (as it also tracks return visits), it's worth noting that it has implications under privacy regulations like GDPR and CCPA since it stores user data.
However, this shouldn't be a major concern as most analytics tools (including Google Analytics and Facebook Pixel) operate similarly—just be sure to update your privacy policy accordingly.
<script>
/**
* Enhanced UTM Parameter Handler for Webflow
* Maintains UTM parameters across sessions using localStorage
* @author BRIX Templates
* @version 1.0.0
* @description Advanced version - persists UTMs across multiple sessions
*/
(function() {
// Wait for the page to fully load
window.addEventListener('load', function() {
// Configuration - adjust these values as needed
const config = {
maxDays: 30, // How long to store UTMs (in days)
storageKey: 'brix_utm_params', // localStorage key for UTMs
debug: true // Set to false to disable console logs
};
// Helper function for logging
const log = (message) => {
if (config.debug) console.log('BRIX Templates:', message);
};
// Get current URL parameters
var params = new URLSearchParams(window.location.search);
// If we have UTMs in the URL, store them
if (params.toString().length > 0) {
try {
localStorage.setItem(config.storageKey, params.toString());
localStorage.setItem(config.storageKey + '_timestamp', Date.now());
log('UTM parameters saved to localStorage');
} catch (error) {
console.warn('Error saving UTMs:', error);
}
} else {
// Try to retrieve stored UTMs
try {
const storedParams = localStorage.getItem(config.storageKey);
const storedTime = localStorage.getItem(config.storageKey + '_timestamp');
if (storedParams && storedTime) {
// Check if stored UTMs are still valid
const daysPassed = (Date.now() - parseInt(storedTime, 10)) / (1000 * 60 * 60 * 24);
if (daysPassed < config.maxDays) {
// Use stored UTMs if they haven't expired
params = new URLSearchParams(storedParams);
log('Retrieved valid UTMs from storage');
} else {
// Clear expired UTMs
localStorage.removeItem(config.storageKey);
localStorage.removeItem(config.storageKey + '_timestamp');
log('Cleared expired UTMs from storage');
}
}
} catch (error) {
console.warn('Error retrieving UTMs:', error);
}
}
// Add UTMs to all links if we have any parameters
if (params.toString().length > 0) {
const links = document.querySelectorAll('a[href]');
links.forEach(function(link) {
try {
const url = new URL(link.href);
params.forEach((value, key) => {
url.searchParams.set(key, value);
});
link.href = url.toString();
} catch (error) {
console.warn('Error processing link:', link, error);
}
});
log('UTM parameters appended to ' + links.length + ' links');
}
});
})();
</script>
Before going live, verify everything works correctly:
While our basic implementation covers most needs, you might require more sophisticated tracking solutions, such as:
If you need help implementing these advanced features or other custom tracking solutions, our team at BRIX Templates can help you create the perfect setup for your specific needs.
Proper UTM parameter tracking is crucial for understanding your marketing effectiveness and ROI in your Webflow site. By implementing either the basic or persistent tracking method, you'll maintain accurate attribution data throughout your visitors' journeys.
Need help with a more complex tracking setup? Our team at BRIX Templates specializes in advanced Webflow implementations. Whether you need custom UTM handling, integration with third-party tools, or other tracking solutions, contact us today for expert assistance.
Discover how to save time by automating lead transfers from Webflow to Klaviyo.
Learn how to automatically truncate long text in Webflow by adding a single custom attribute. 5-minute setup, no coding experience needed
Step-by-step guide to bypass Webflow's 3-field checkout limit. Learn how to add unlimited custom fields to your Webflow Ecommerce checkout.