Skip to content

Instantly share code, notes, and snippets.

@joshuatz
Created April 1, 2019 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuatz/885a976c3db22baa412804b8f311dc75 to your computer and use it in GitHub Desktop.
Save joshuatz/885a976c3db22baa412804b8f311dc75 to your computer and use it in GitHub Desktop.
<!-- Use this to set the list of IP addresses you DONT want your tags loading for -->
<?php $blockTagsFor = array('216.3.128.12','19.117.63.126','2001:0db8:85a3:0000:0000:8a2e:0370:7334'); ?>
<?php if (in_array($_SERVER['REMOTE_ADDR'],$blockTagsFor,false)==false): ?>
<!-- Put all the tags you want to conditionally load here. GA example below: -->
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_MEASUREMENT_ID');
</script>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment