How can I display "Amazon Ads" only for the U.S visitors?

How can I display “Amazon Ads” only for the U.S visitors? Is there any way to do it? Since my website is fully cached by Cloudflare Edge. No Wordpress plugin works for this feature in full cache mode of Cloudflare.

Any help?

If your website wasn’t fully cached by Cloudflare, how would you do this?

I have 2 different wordpress plugins which does the job.

  1. Custom Content by Country Plugin - https://wordpress.org/plugins/custom-content-by-country/ (free)
  2. Ad Inserter Pro - Paid Version :- https://wordpress.org/plugins/ad-inserter/

I have both but both of them will work only in non-cached pages.

Cloudflare cache is specific to that datacenter. So if a visitor from France hits your site, that edge node should cache the French version of your page.

No, it doesn’t work.

I have this configuration:-

Visitor from the U.S = Amazon U.S link
Visitor from India - Amazon India link

But this works only in non-cached version

On the cached version, everything is the U.S link (or if the first vistor is from India then the Indian link will be served to all other visitors, I guess)

Are you running Argo? (Not Argo tunnel)

I had a very brief look at the source for the first plugin you listed, and it appears the developer has explicit support for Cloudflare. Make sure you have enabled Geolocation in Cloudflare.

You can test that it is correctly working by taking Cloudflare out of the process, and making a request directly to your backend. Try something like this, replacing the relevant variables. Does the output match the expected country if you make several requests with different country codes?

curl https://yourdomain.com/your-path --resolve yourdomain:443:your-origin-ip-address -H "cf-ipcountry: fr"

As @sdayman said, the POPs are generally country specific, but that is not always the case, especially if you have Argo enabled with Tiered Caching. It is generally not possible to vary the responses per request while also caching all requests at the edge (this is same problem no matter what CDN you use). You may need to come up with a different strategy, such as doing the customisation in a Worker.

1 Like

I’m not sure the plugin’s CF-Geolocation feature would trigger if the page is cached at an edge node.

It won’t, edge caching and per-user customisation of the payload don’t mix.

1 Like

This topic was automatically closed after 14 days. New replies are no longer allowed.