Problems Implementing Google Tag Manager

Options
Good Morning,

We have recently attempted to move from Google Analytics (GA) to Google Tag Manager (GTM).  An issue we have run into is that the GTM script needs to be placed immediately after the <body> tag.  Placing it inside the individual layouts doesn’t work. As advised by Blackbaud customer support, I have attempted to put it into an “Unformatted Text” part and using the advanced options section with partial or no success. 

When using the options for “Placement in HTML” the first option “in the <head> tag” placing it in the <head> tag it will work somewhat.  Meaning that Google Tag Manager will notice that you have placed it on the website, but it will send back an error that your script is in the wrong area, and because of this important features are not available to use.

If we attempt to try the other two options which are inside the <body> tag or at the end of the <body> tag. Then Tag Manager doesn’t see the code at all.

What I would like to have is another possible drop down in the “Placement in HTML:” that would allow to put code right after the <body> tag before the <form> tag starts.

Thank you

-Craig

 
Tagged:

Comments

  • Hello Craig,



    You can use JS to prepend this script to your page <body>. I would try adding this script at the bottom of your Layout. Be sure to replace CODE SNIPPET with what GTM provides you. I've added in no conflict assuming your NC install has the default, depreciated version reference of jQuery. Let me know if you have issues with this solution.

     
    <script>


    $.noConflict();

    $( document ).ready(function() {

    $('body').prepend('CODE SNIPPET');

    });

    </script>



    Good luck!



    Chris McGrane

     
  • Hey Chris, 



    Thank you for the response.  I attempted to put your code into the layout, but after I submitted the change, the system placed <p> tags around portions of the code. 



    I also attempted to put the code into an unformated text part and try it with different HTML placements.  None of those worked either. 



    Thank you very much for the idea.



    -Craig
  • Placing the code anywhere in the <body> works fine when firing successful donation events.  We push directly onto the Data Layer, so that may be a key difference.  Regular tags don't communicate with the Data Layer in this manner.



    Please provide a link to the page that isn't working, and we can help with some testing.  



    There's no way to add directly after the <body> tag in BBNC currently.  Although, if we discover that the tag placement is indeed the problem, then you could force the tag into position with JS.
  • Hello Craig,



    I'm aware that scripts are surrounded by paragraph tags upon submitting changes, although they should still execute correctly. Be sure that you're adding the script tag within the HTML editor of the page or layout editor. You can test to see if this works with a simple console test. I can confirm that I've been able run JS anywhere in BBNC with this method. For more advanced JS users, you can also hook into Net Community's API which allows for some conditional part rendering.



    Thank you,



    Chris M
  • Julie Gibson:

    Placing the code anywhere in the <body> works fine when firing successful donation events.  We push directly onto the Data Layer, so that may be a key difference.  Regular tags don't communicate with the Data Layer in this manner.



    Please provide a link to the page that isn't working, and we can help with some testing.  



    There's no way to add directly after the <body> tag in BBNC currently.  Although, if we discover that the tag placement is indeed the problem, then you could force the tag into position with JS.

    Adding on with more information:

    When we implement Google Tag Manager, we place the code as close as possible to the opening body tag and it works correctly.

Categories