How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Russell H. Your Own Question

Russell H.
Russell H., Computer Systems Expert
Category: Computer
Satisfied Customers: 9513
Experience:  13+ years experience
13568747
Type Your Computer Question Here...
Russell H. is online now
A new question is answered every 9 seconds

We are having difficulties placing the tag manager code

Customer Question

We are having difficulties placing the tag manager code below into CMS Composite pages in our site. Has anyone experienced this and was their a fix?
This should be the code that should be live on the site:
(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=
'//DANGEROUS URL REMOVED?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PW2JDW');
Submitted: 4 months ago.
Category: Computer
Expert:  Russell H. replied 4 months ago.

Hi, thank you for contacting JustAnswer.com. My name is Russell. I will do my best to provide the right answer to your question.

That code is probably JavaScript code. But it might be some other language of code.

What difficulty are you having with insertion of the code? error messages, perhaps? or just, non-function?

Customer: replied 4 months ago.
Are you a google expert? I just want to make sure that I am not waisting your time. This is Javascript and it is the code that is given from Google when setting up a Tag Manager in the Google Analytics account. We should be able to place this in our code of the web site or CMS content management system which is Composite.
Expert:  Russell H. replied 4 months ago.

OK. You should be able to just insert the code block, within a JavaScript code block, on a page you want it to work with.

Do you know how to edit a web page, in HTML code, and insert such a JavaScript code block?

If so, you have the abilities you need, I think, for this task.

Customer: replied 4 months ago.
We place it in our layout pages, and all pages that use those layouts inherit the tag right after the <body> element.The error we are seeing after we add the complete tag is some generic "SERVER ERROR, please update your configuration to see the rest of the error" message when the page loads.So I am not sure we are on the same page with this. I don't think my question was answered.
Expert:  Russell H. replied 4 months ago.

OK. I think the tags must be misinterpreted owing to incorrect context in the pages.

After the <BODY> tag may or may not be the correct placing. But, you need to surround the code with a JavaScript code block, so that in toto the code added looks more or less like this:

<SCRIPT type="text/javascript">

(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=
'//DANGEROUS URL REMOVED?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PW2JDW');

</SCRIPT>

with my alterations in Bold face.

If the <SCRIPT ... > and </SCRIPT> tags do not surround it, it may not be correctly interpreted as JavaScript code.

Also, forgive my JustAnswer system... it removed part of the code, where this transliteration has 'DANGEROUS URL REMOVED'... fill in that part with appropriate code, or copy and paste from your own... I only altered this in any way aside from that (done by the JustAnswer system) by adding the SCRIPT and /SCRIPT at head and foot of the block of code.

Try that. Let me know if it alters the error message... if it works, please rate my answer (favorably) so that this case may be closed. Thanks.