Can I render google tag manager scripts server side?












0















I'm looking into google tag manager and would like to avoid making a request from the client to render the tags. Is it possible to request the tags from GTM on the server and render them up front?










share|improve this question



























    0















    I'm looking into google tag manager and would like to avoid making a request from the client to render the tags. Is it possible to request the tags from GTM on the server and render them up front?










    share|improve this question

























      0












      0








      0








      I'm looking into google tag manager and would like to avoid making a request from the client to render the tags. Is it possible to request the tags from GTM on the server and render them up front?










      share|improve this question














      I'm looking into google tag manager and would like to avoid making a request from the client to render the tags. Is it possible to request the tags from GTM on the server and render them up front?







      google-tag-manager






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 15:59









      DanDan

      2,57911429




      2,57911429
























          1 Answer
          1






          active

          oldest

          votes


















          0














          No (*). Not only is GTM itself a client-side technology, most marketing tags likewise require to be run in the browser.



          There are a few things like Google Analytics or Google Ads conversion tags that can be run on the server (although the implementation is very much different from the JS tags), but GTM has no part in that. If you want vaguely similar functionality to GTM that moves at least a part of your tags out of the client-side code you should look at a service like segment.com (I am not affiliated. Segment.com is not free).



          (*) Not in any meaningful sense of the world. Just to cover every angle, you could download the GTM javascript file and run it in a headless browser on the server or something similarly stupid, but there would be no point, and I just mentioning it to pre-empt smartass comment to that effect.






          share|improve this answer
























          • Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

            – Dan
            Jan 3 at 10:30








          • 1





            In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

            – Eike Pierstorff
            Jan 3 at 10:54











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009399%2fcan-i-render-google-tag-manager-scripts-server-side%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          No (*). Not only is GTM itself a client-side technology, most marketing tags likewise require to be run in the browser.



          There are a few things like Google Analytics or Google Ads conversion tags that can be run on the server (although the implementation is very much different from the JS tags), but GTM has no part in that. If you want vaguely similar functionality to GTM that moves at least a part of your tags out of the client-side code you should look at a service like segment.com (I am not affiliated. Segment.com is not free).



          (*) Not in any meaningful sense of the world. Just to cover every angle, you could download the GTM javascript file and run it in a headless browser on the server or something similarly stupid, but there would be no point, and I just mentioning it to pre-empt smartass comment to that effect.






          share|improve this answer
























          • Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

            – Dan
            Jan 3 at 10:30








          • 1





            In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

            – Eike Pierstorff
            Jan 3 at 10:54
















          0














          No (*). Not only is GTM itself a client-side technology, most marketing tags likewise require to be run in the browser.



          There are a few things like Google Analytics or Google Ads conversion tags that can be run on the server (although the implementation is very much different from the JS tags), but GTM has no part in that. If you want vaguely similar functionality to GTM that moves at least a part of your tags out of the client-side code you should look at a service like segment.com (I am not affiliated. Segment.com is not free).



          (*) Not in any meaningful sense of the world. Just to cover every angle, you could download the GTM javascript file and run it in a headless browser on the server or something similarly stupid, but there would be no point, and I just mentioning it to pre-empt smartass comment to that effect.






          share|improve this answer
























          • Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

            – Dan
            Jan 3 at 10:30








          • 1





            In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

            – Eike Pierstorff
            Jan 3 at 10:54














          0












          0








          0







          No (*). Not only is GTM itself a client-side technology, most marketing tags likewise require to be run in the browser.



          There are a few things like Google Analytics or Google Ads conversion tags that can be run on the server (although the implementation is very much different from the JS tags), but GTM has no part in that. If you want vaguely similar functionality to GTM that moves at least a part of your tags out of the client-side code you should look at a service like segment.com (I am not affiliated. Segment.com is not free).



          (*) Not in any meaningful sense of the world. Just to cover every angle, you could download the GTM javascript file and run it in a headless browser on the server or something similarly stupid, but there would be no point, and I just mentioning it to pre-empt smartass comment to that effect.






          share|improve this answer













          No (*). Not only is GTM itself a client-side technology, most marketing tags likewise require to be run in the browser.



          There are a few things like Google Analytics or Google Ads conversion tags that can be run on the server (although the implementation is very much different from the JS tags), but GTM has no part in that. If you want vaguely similar functionality to GTM that moves at least a part of your tags out of the client-side code you should look at a service like segment.com (I am not affiliated. Segment.com is not free).



          (*) Not in any meaningful sense of the world. Just to cover every angle, you could download the GTM javascript file and run it in a headless browser on the server or something similarly stupid, but there would be no point, and I just mentioning it to pre-empt smartass comment to that effect.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 18:52









          Eike PierstorffEike Pierstorff

          25.2k32447




          25.2k32447













          • Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

            – Dan
            Jan 3 at 10:30








          • 1





            In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

            – Eike Pierstorff
            Jan 3 at 10:54



















          • Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

            – Dan
            Jan 3 at 10:30








          • 1





            In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

            – Eike Pierstorff
            Jan 3 at 10:54

















          Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

          – Dan
          Jan 3 at 10:30







          Just to be clear, I didn't want to execute the scripts on the server, only render them, for performance reasons

          – Dan
          Jan 3 at 10:30






          1




          1





          In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

          – Eike Pierstorff
          Jan 3 at 10:54





          In that case it might be easier to forego GTM altogether and just insert your tags into the source code of your page. This will save you the GTM boilerplate code (some 100KB unzipped) and a bit of DOM manipulation GTM does to insert the tags. This might give you a small performance boost at the expense of the convience that GTM provides (not sure if it's worth it, though).

          – Eike Pierstorff
          Jan 3 at 10:54




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009399%2fcan-i-render-google-tag-manager-scripts-server-side%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas

          Can't read property showImagePicker of undefined in react native iOS