Question

Can someone tell me how to force SSL in Google Tag Manager? Google has documentation on how to force SSL for Google Analytics. But I cannot seem to find one for Tag Manager. Also, it does not look like I have access to ga object either, so I cannot set that config.

Was it helpful?

Solution

I don't know any official answer, but it should work if you change the protocol-less urls for the tag manager code to always use ssl:

<!-- Google Tag Manager -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->

See the change to the iframe source attribute and source attribute for js injection in the first and sixth line respectively to include the protocol. That is not a change that could be done via the GTM interface (since the code has to be loaded before the settings take effect).

UPDATE: I misunderstood the question (which really was how to force the Google Analytics tag inside to tag manager to SSL). This can be done in two ways, either via "set Fields" (with forceSSL als field name and true as value) or simply by checking "always use SSL" in the advanced configuration tab.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top