Cloudflare challenges breaking GA4 campaign attribution

Cloudflare challenges and interstitial redirects can strip UTMs and referrers, so campaigns land in Direct. How it happens and how to fix it.

You run a B2B platform with thousands of daily visitors. Following a minor bot attack, your IT department implements a strict Cloudflare security policy to protect the server. The site stays up, the bots are blocked, and IT declares a victory.

On Monday morning, your Google Ads and LinkedIn dashboards show a healthy volume of clicks. When you check Google Analytics 4, the campaign traffic has plummeted by 80%. In its place is a massive, sudden spike in Direct traffic.

Analytics platforms are fragile. They rely on the browser carrying a tiny parcel of information (the HTTP referrer and the URL query string) from the ad to your website.

When you put a Content Delivery Network (CDN) security challenge in front of your website, you are putting up a border control checkpoint. If that checkpoint strips the luggage from the passenger before letting them through, GA4 has no idea where they came from.

The mechanics of an interstitial challenge

To understand the attribution loss, you have to look at what happens in the three seconds between a user clicking an ad and seeing your homepage.

A user clicks a Google Ad. The URL in their browser contains ?gclid=12345 (Google's click identifier). They arrive at your server.

Because the IT department has enabled a "Managed Challenge" or "Bot Fight Mode" in Cloudflare, the user does not see your website. They see a blank white page that says "Checking your browser before accessing..."

This is an interstitial page. It sits on Cloudflare's servers, not yours.

Once the user's browser passes the automated security check, Cloudflare issues a redirect to send them to the actual landing page. This redirect is where the marketing data dies.

First, the HTTP referrer is overwritten. The user did not arrive at your landing page from Google; they arrived from the Cloudflare challenge page on your own domain. GA4 sees this as a self-referral or a direct visit.

Second, unless Cloudflare's Transform Rules are explicitly configured to "Preserve Query String", the ?gclid= or ?utm_source= parameters are stripped off the URL during the redirect.

The user lands safely on your site. They have no UTM tags, and their referrer is empty. GA4 drops them into the Direct bucket.

What it does to your commercial decisions

If your paid media agency is judged on the conversions they drive in GA4, a strict WAF implementation will make it look like they stopped doing their job overnight.

The journey of a challenged ad click

What the user experiencesWhat the CDN doesWhat GA4 reports
Clicks a LinkedIn ad with ?utm_source=linkedin.Intercepts the request. Serves the Challenge page.(GA4 script has not loaded yet).
Waits 3 seconds for the security check.Validates the browser. Issues a redirect to the landing page.(GA4 script has not loaded yet).
Browses the site and submits an enquiry.(Server role finished).Checks the URL. Finds no UTMs. Checks the referrer. Finds it empty.
The commercial resultA secure, bot-free server environment.100% of LinkedIn ROI is credited to Direct traffic.

When you lose campaign attribution, you lose the ability to optimise your budget. If a £10,000 LinkedIn campaign generates 50 leads, but GA4 attributes them all to Direct, the finance team will pull the LinkedIn budget next month.

Consider an enterprise software company running high-value Search and Social campaigns.

Illustrative figures: The security tax

Traffic SourceClicks Paid ForConversions (Before WAF)Conversions (After WAF)
Google Ads (Non-Brand)2,500454 (Passed without challenge)
LinkedIn Sponsored1,200180 (All challenged)
Email Newsletter4,0008012 (Mostly challenged)
Direct TrafficN/A30 (Baseline)157 (Inflated)

The leads are still entering the CRM, but they are completely divorced from the marketing spend that generated them. Your advertising platforms lose the conversion signals they need to train their bidding algorithms, causing your Cost Per Acquisition to spiral out of control.

How we bypass the border control

We check what happens all the way through your server infrastructure. If your IT department's security measures are breaking your marketing attribution, we investigate the CDN rules and explain what needs changing.

The fix requires bridging the gap between security and marketing. We do not ask IT to turn off the firewall; we ask them to configure it intelligently.

First, we address the query strings. We audit the Cloudflare Page Rules and Transform Rules. We ensure that any redirect happening at the edge is explicitly configured to "Preserve Query String". We test this using command-line tools to verify that a URL with a fake utm_source retains that tag after passing through the challenge.

Second, we protect the high-value traffic from the challenge entirely. Bots rarely use UTM parameters, and they never use valid Google Click IDs (gclid). We work with your DevOps team to write a WAF exception rule. If the incoming URL contains gclid or standard utm_ parameters, and the IP address does not belong to a known bot network, the WAF bypasses the Managed Challenge and lets the user straight through.

Finally, if the business insists on challenging all traffic regardless of the source, we implement tracking on the challenge page itself. Cloudflare allows enterprise users to upload a Custom Challenge Page. We embed your Google Tag Manager script into this custom HTML template.

When the user hits the challenge page, the GA4 script fires immediately. It captures the original Google or LinkedIn referrer and the intact UTM parameters before the redirect happens.

The aim is straightforward. Your server must remain secure against automated attacks, but your marketing team must be able to prove which campaigns are keeping the business afloat.

Frequently asked questions

Does this only happen with Cloudflare?

No. Any Web Application Firewall (WAF) or CDN that uses an interstitial challenge page, such as Akamai, Fastly, or Imperva, will break the attribution chain if it strips query strings or overwrites the HTTP referrer during the redirect.

Why does GA4 not see the original referrer after the redirect?

The HTTP protocol dictates that when a browser is redirected (via a 301 or 302 status code or a JavaScript refresh), the referrer for the final destination becomes the URL that issued the redirect. If the redirect comes from your own domain's challenge page, GA4 sees a self-referral and defaults to Direct.

Can we just look at the clicks in Google Ads instead of GA4?

You can, but Google Ads will only show you the clicks. If the conversion tracking pixel on your website relies on GA4 (or if the challenge page strips the gclid), Google Ads will not record the conversion either. Your bidding algorithms will still fail.

Does Bot Fight Mode affect organic search traffic?

Yes. Aggressive bot protection often challenges legitimate users clicking through from Google Organic search. Because organic search does not use UTM parameters, preserving the query string will not help. You must rely on a Custom Challenge Page with embedded tracking to capture the organic referrer.

Should we ask IT to disable the WAF for all landing pages?

No. Landing pages are frequent targets for DDoS attacks and form-spam bots. You should refine the WAF rules to skip challenges for traffic containing specific, validated marketing parameters, rather than disabling protection entirely.

Related reading