Skip to content

Tracking4 min read

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.

(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; }

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 May 20, 2026

Sandro DA SILVA

Growth Marketer, Webflow expert, and jack-of-all-trades. Sandro handles commercial operations, ensures projects run smoothly, and addresses marketing-related issues (SEO, Tracking, Copywriting, etc).

You might be interested in these tutorials

Related tutorials

See all

You're going to working with us, guaranteed

Ready to launch your business?

get a quote

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