Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 1
Bala1570047874

How to add a code inside the body element?

Question

17 answers to this question

Recommended Posts

  • 0

You should add it to the Footer Code Injection Point, this will add it to the end of each page before the closing </body>

Edited by silvabokis

Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 4

I couldn’t get the tag manager to work when it was in the header. The code seemed to load, and I didn’t get an errors in my console when I stuck the GTM code in the header (or footer), but when I used the Tag Assistant (Google Chrome extension) it gave me an error that said my tag was detected, but it wasn’t in the correct place (which is right after the opening <body>).

These instructions worked for me: How to inject the Google Tag Manager script into a Squarespace template with jQuery – hope that helps!

Edited by lauren2234

Share this post


Link to post
  • 3

lauren2234 , Chris here, I wrote that post. I'm glad you found it helpful! If anyone has any questions about adding GTM , shoot me an email.http://www.chriseisenbraun.com/news

Edited by ceisenbraun

Share this post


Link to post
  • 1

Following these instructions inserts the code into the Head of the page not the Body.

Can you please advise how you get it in the body and not the head of the page.

Thanks.

Share this post


Link to post
  • 0

Thank you Silva, I do know that pasting the code in the footer will inject it before the closing body tag but i need to inject the code right after the opening body tag. Google tag manager will not work if the code is not in the right place which is right after the opening body tag.

Share this post


Link to post
  • 0

got the same problem with google tag manager. it still works if injected in the header, but webmasterstools wont allow it as verification anymore


online marketing lover

Share this post


Link to post
  • 0

Following these instructions inserts the code into the Head of the page not the Body.

Can you please advise how you get it in the body and not the head of the page.

Thanks.

Share this post


Link to post
  • 0

Hi Chris, Your instructions on your page result in the code being injected in the header before the body. Is it possible to get the code immediately after the body? If so how?Thanks :)

Share this post


Link to post
  • 0

Hello Colinc. In my instructions, I use - jQuery('body').prepend - to add the script. This will prepend the script (or elements, etc) as the first child of the

element. It will not add anything to the . I'm unclear why you suggest it would. If I'm misunderstanding something, please let me know. Thanks!

Share this post


Link to post
  • 0

Doesn't using jQuery to insert the script mean that it will only start running after the document has completely loaded, thus possibly missing events?


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
Guest
This topic is now closed to further replies.

×
×
  • Create New...