

You might know however, that GA can also send POST requests and use the browser’s beacon function to send information more reliably. This works quite well if you want to do basic tracking with Google Analytics. Any resource loaded from the same domain.When we use the above CSP, we’ll find that it blocks everything except: In a meta tag in the actual HTML of the page.In your browser’s network tab, under the headers for the request to load the page.A Content Security Policy to deal with this highly advanced Cat GIF page could look something like this:ĭefault-src 'self' img-src script-src
#Custom html tags code
That ‘other’ thing could be your self-hosted cats.gif image you’d like to show the world or the Google Analytics tracking code to see how many people have looked at your cat GIF.
#Custom html tags how to
Your browser, the beacon of light trying to protect you from all the bad out there in the digital world, has no way to distinguish those ‘good’ scripts from the ‘bad’ scripts trying to steal your credit card information.Īs site owners we can help the browser protect you from malicious code by telling it how to deal with code that connects to anything other than the current document being loaded. Google Tag Manager is a great way to serve a random collection of scripts and images (tags) that help you do all sorts of things like tracking purchase conversions for Facebook Ads, tracking funnels with Google Analytics or even send Slack messages when a user sees a 404 page.


To prevent your precious Google Tag Manager implementation -and your entire site for that matter- from falling victim to malicious code taking over checkout funnels or secretly listening to form input from visitors it’s time to implement a Content Security Policy (CSP). If you think chaos is beautiful, that is, because it is also a place where everyone and everything is hacked, abused, and manipulated for money, status or just the lolz.
