wp_enqueue_script based on country
-
Hi
im using below code to enqueue google AdSense only for US, I have an issue on caching, If a US visitor visits the page this enqueue get cached and show to non US visitors as well. Is there a way to prevent this from happening ?
if ($countryIsoCode !== null && $countryIsoCode == "US") { wp_enqueue_script( 'adsbygoogle', // Script handle 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-{pub_id}', // Script URL array(), // Dependencies (none in this case) null, // Version (null to prevent caching) false // Load in the footer (true) or header (false) ); }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘wp_enqueue_script based on country’ is closed to new replies.