Add GAD string - Query parameters and cached responses

can you add GAD to this list: Query parameters and cached responses · Cloudflare Automatic Platform Optimization docs

It comes from Google Ads and will be added to all traffic coming from google Ads. See this:

Blockquote
Any URL coming from a Google ad now has &gad=1 in its final URL. This parameter is not customizable and is the same for all advertisers and campaigns.
Note: The gad parameter will be gradually rolled out in the coming months. Some advertisers may not find the gad parameter in their URLs yet.

can you please add this to the list?

could someone please look at this?

I hope you get a prompt response, but it may take a while.

Besides the Cache Rule I’ve suggested as a workaround in your previous thread, there’s an even better way to make the gad=1 parameter get cached by APO.

Create a Transform Rule to remove the query string when the gad=1 parameter is present:

When incoming requests match...
SSL (on)
Hostname equals apo.example.com <<< your APO hostname, if applicable.
URI Query String contains "gad=1" (*** see note below)

Then
Path: Preserve
Query: Rewrite to...
Static: (leave value empty)

This will remove the query string when the URL is passed to Cloudflare cache or your origin.

When the full ad-URL, with all its parameters, is clicked, the Google Ads and Google Analytics JavaScript scripts in the visitor’s browser will process it accordingly, but your Cloudflare cache (or your origin) will only receive a request for the URL without the query string.

Removing the query string upstream is exactly what will happen if and when the APO decides to add the gad=1 parameter to their list, with one major difference. APO’s logic will treat as dynamic content if the URL contains other query string parameters besides the ones in their marketing list so that /utm_source=x&gad=1 would have the query string removed, while /my-query&gad=1 wouldn’t.

Meanwhile, the suggested Transform Rule will remove the whole query string in both cases. That shouldn’t be an issue for an ad, as their query strings do not normally contain elements that need processing by the origin, unless a query string parameter defines what content should be returned (something like. /path/to/page?page_number=123&gad=1), in which case a more complex Transform Rule would be needed.

*** Despite Google Ads’ own working about it, the gad=1 parameter should only contain & if it’s appended to a pre-existing string (ex.: /path/to/page?param1&gad=1). Otherwise, it’s added by itself: /path/to/page?gad=1

@cbrandt
Thank you very, very, very much! It works very well! You re our hero!

It works like it did before and APO is usefull for us again!

1 Like

You’re welcome. I’m glad it worked for you.

Please note that I’ve just edited the suggested rule above to add the field SSL. The idea is that the TR should only apply after any redirection has occurred, so that the query string is removed from the same request that receives the content from the origin/cache, and therefore the browser JavaScript engine will process the query string as expected.

Update: Google has changed the query string to:

?gad_source=1