Page 1 of 1

Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 8:07 am
by tba
Hi.
I am trying to connect a Gooogle ad campaign to my website and have used the Google tag manager to generate the TAG code to be inserted in the page <head> and <body> sections as follows

HEAD
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var =d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js ... efore(j,f);})(window,document,'script','dataLayer','GTM-PD5KD8NL');</script>
<!-- End Google Tag Manager -->

BODY
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.htm ... "height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Google TAG manager however gives the following error message;

A timeout occurred while attempting to connect to https://www.gubbhost.se/

I have loaded this website into my browser and used the inspector to see if the code is there .. you can check this for yourself.

My consultant at Google suggests the problem is caused by the Google Tag not being high enough in the <head> section.

Can you confirm that this is the cause of the problem or if not then perhaps suggest what could be causing the issue.

Many thanks

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 9:09 am
by Pablo
You have placed the code in the wrong section of the page.
The code is inside the body tag, this is incorrect. This section may only have HTML attributes.

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 9:41 am
by tba
no I don't think so. Can I upload a screenshot to this forum?

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 9:46 am
by BaconFries
No not directly as uploading image to the forum is disabled. As an alternative you can use the following.https://imgbb.com/
or you can upload to your own host/server and provide a url to it.

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 10:01 am
by tba
I have removed the code from the <body> section and uploaded the page and verified that it has been updated but the problem remains. The google code is in the <head> section of the page but the tag manager can not connect

I surely am not the first person to attempt this using a page created with WYSWYG ?

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 10:28 am
by BaconFries
no I don't think so. Can I upload a screenshot to this forum?
As Pablos reply you have placed the code inside the body tag

Code: Select all

<body 
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.htm ... "height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) ->>  
This can be seen in the html see screenshot to show this
Image

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 10:30 am
by Pablo
If you want to place the code at the top of head tag then you will need to place in 'user defined' section of the meta tags.

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 11:52 am
by tba
ok done that and now Google tag manager can connect but gives the following error message

https://ibb.co/YQ17gd0

also curious as to why the code is still in the <head> section when it has been removed ? (bug??)

https://ibb.co/NZcryH0

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 12:06 pm
by tba
also it seems that there is an error in the Google Tag code... could this be the problem?

https://ibb.co/d7Zzskn

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 12:07 pm
by crispy68
One problem i see from your screenshot it that you have the <script> tag before the Doctype!
This is incorrrect. Remove this.

the script tag should be placed in the <head> section as close as possible to the opening <head> tag if possible. The <no script> tag should be placed immediatley after the <body> tag (this can be chosen as one of the options in the html box).

I don't think you should have an issue if the <script> tag is not the first thing in the head but test and see. Publish the page to your disk and then open the html page in notepad and move the <script> tag up right after the head tag and upload it to your server and see if it makes a difference.

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 12:37 pm
by tba
""(this can be chosen as one of the options in the html box).""

where can I find 'the option box' in the HTML box?

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 12:45 pm
by crispy68
In the "Type" drop down box.

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 12:56 pm
by tba
hmmm.. are we using the same system?

https://ibb.co/DKXkMbz

Re: Problem connecting with Google tag manager

Posted: Fri Jul 28, 2023 1:01 pm
by tba
problem solved. The Google tag must be directly after the <head> tag thus...

<!doctype html>
<html lang="sv">
<head>
<!-- Google Tag Manager -->
<script>(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='https://www.googletagmanager.com/gtm.js ... efore(j,f);})(window,document,'script','dataLayer','GTM-PD5KD8NL');</script>
<!-- End Google Tag Manager -->
<meta charset="utf-8">
<title>Gubbhöst teater i eskilstuna teater i sörmland riksteatern sörmland</title>

-------------------------

now Google tag manager can connect. If this is correct then pls (Pablo) update the online help. If this is incorrect pls suggest the correct and tested way of doing this