Can I render google tag manager scripts server side?

Multi tool use
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
add a comment |
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
add a comment |
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
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
google-tag-manager
asked Jan 2 at 15:59


DanDan
2,57911429
2,57911429
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
auGgIVJXl,T aP0lAyJGsKZDDk M5,s9,L725PXYOfRWct