How to force SSL in Google Tag Manager

Tag: javascript , ssl , google-tag-manager Author: zijiei Date: 2014-04-23

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.

Best Answer

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=""
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- 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).


Tried this, finally. Yes, the initial request to get gtm.js is now over HTTPS. However, each individual event logging is still via HTTP.
Sorry, misunderstood what you where looking for. In the tag manager go to your analytics tag, expand "more settings", search for "fields to set" and enter forceSSL as field name and true as value.