Ajouter

Lorem ipsum

Lorem ipsum

Tracking

16 views

4 min

How to Detect Traffic Sources and Adapt Content in Webflow

Learn how to detect a visitor’s traffic source and dynamically adapt your Webflow page content.

In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to detect a visitor’s traffic source and dynamically adapt the content on your Webflow page.

Example

Simulate a traffic source

SourceDetectionExample
utm_sourceURL parameter?utm_source=linkedin
Googledocument.referrergoogle.com in the referrer
LinkedIndocument.referrerlinkedin.com in the referrer
DirectEmpty referrerDirect access or bookmark
Metadata-traffic-source attributeCSS targeted by source

1. Add the dynamic elements in Webflow

Create a Text Block with the ID source-message for the dynamic message. To show an element only for a specific source, add the custom attribute data-show-source with the value linkedin, google, or meta. Set these elements to display: none by default.

2. Add the script in Footer code

(function() {
var params = new URLSearchParams(window.location.search);
var ref = document.referrer;
var source = params.get('utm_source') || '';

function getSource() {
if (source) return source.toLowerCase();
if (ref.includes('linkedin')) return 'linkedin';
if (ref.includes('twitter') || ref.includes('x.com')) return 'twitter';
if (ref.includes('google')) return 'google';
if (ref.includes('facebook') || ref.includes('instagram')) return 'meta';
if (ref === '') return 'direct';
return 'other';
}

var src = getSource();
document.body.setAttribute('data-traffic-source', src);

// Dynamic content based on source
var messages = {
'linkedin': 'Welcome from LinkedIn! See how we help B2B teams.',
'google': 'You found us on Google. Here’s what we do.',
'meta': 'Welcome from our ads! Here’s our offer.',
'direct': 'Welcome! Here’s what Gemeos does.',
'other': 'Welcome to Gemeos.'
};

var el = document.getElementById('source-message');
if (el) el.textContent = messages[src] || messages['other'];

// Show/hide elements by source
document.querySelectorAll('[data-show-source]').forEach(function(el) {
var sources = el.dataset.showSource.split(',');
el.style.display = sources.indexOf(src) !== -1 ? '' : 'none';
});
})();

3. Source-based CSS customization

The script adds a data-traffic-source attribute to the body. You can target sources in CSS:

/* In a global CSS embed */
[data-traffic-source='linkedin'] .hero-cta { background: #0077b5; }
[data-traffic-source='google'] .promo-banner { display: block; }

good to know

document.referrer is empty when a visitor comes from HTTPS to HTTP, from a link in an app (Slack, native email), or directly. The utm_source parameter is more reliable because you control it. Combine both: utm_source first, referrer as a fallback. For email campaigns, always add utm_source=email for reliable detection.

Conclusion

Adapting content to the source improves relevance and conversion rates. Use cases:

  • Personalized welcome message based on the campaign
  • Different CTA for LinkedIn vs Google visitors
  • Special offer visible only from a Meta ad

Source detected in your current session

data-traffic-source :

Detecting...

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...