Considering the script tag should be a tag I have deleted the script tags from the code but nothing is changing and isn't working.I have this tag in the menu component because I want to add it in all pages and not adding using Head Assets.Is this possible?", "author": { "@type": "Person", "name": "unicodes", "image": "https://cdn.discordapp.com/avatars/1117897194134052925/c82b3fa769ed6e6ffdea579381ed5f5c", "url": "https://discordapp.com/users/1117897194134052925" }, "datePublished": "2025-03-10T22:29:45.91+00:00" }, { "@type": "Comment", "text": "It says “google url”", "author": { "@type": "Person", "name": "Andreas Møller", "image": "https://cdn.discordapp.com/avatars/282143925291057163/2b00be4ec537a0305354613c036a2fcd", "url": "https://discordapp.com/users/282143925291057163" }, "datePublished": "2025-03-14T05:38:06.03+00:00" }, { "@type": "Comment", "text": "Hi Andreas,I changed the values because I want to keep the data \"safe.\"My question is: how can I use the Considering the script tag should be a tag I have deleted the script tags from the code but nothing is changing and isn't working.I have this tag in the menu component because I want to add it in all pages and not adding using Head Assets.Is this possible?" }
Pricing Blog

Script TAG, how to add gtag in the script input.

  • uunicode-1348784927423856671

    unicodes

    4 months ago

    I added this code but isn't working.

    <script async src="google url"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-4534543543543');
    </script>

    Considering the script tag should be a tag I have deleted the script tags from the code but nothing is changing and isn't working.
    I have this tag in the menu component because I want to add it in all pages and not adding using Head Assets.

    Is this possible?
  • andreasmoller-1349979885136777237

    Andreas Møller

    4 months ago

    It says “google url
  • uunicode-1350046706896736338

    unicodes

    4 months ago

    Hi Andreas,

    I changed the values because I want to keep the data "safe."
    My question is: how can I use the <script> tag to add a Google Tag?
    Currently, I have installed the Google Tag by adding it to the Head assets of each page, but it would be much easier to include it in a component and have it applied to all pages. I know that using the <script> tag will place it in the body rather than the head of the page, but I would be interested in trying it to see if it works. If not, having such a tag for the head as well would make things much easier. Currently, the head assets are functional but not practical.
  • uunicode-1350047538505449502

    unicodes

    4 months ago

    What I mean by "practical" is that removing or editing information requires checking each page individually instead of making changes in a single place / component.
  • lucasg-1350072193635319850

    Lucas G

    4 months ago

    Tags in components work for me. It’s how I use them on my main site
  • uunicode-1350087248972091515

    unicodes

    4 months ago

    @Lucas G can you please share a screen how you added them?
  • It worked for me to but in reality https://tagassistant.google.com doesn't see it.
  • And if Tag Assistant doesn't see it, it means that isn't working.
  • uunicode-1350087824656961648

    unicodes

    4 months ago

    I'm curios how you added the code in the script tag, maybe I'm doing something wrong.
  • lucasg-1350089692426534913

    Lucas G

    4 months ago

    What do you mean it worked for you?
  • Are you seeing data in console?
  • For the script you posted, it's a 2 part thing so you'll need to configure each one
  • lucasg-1350090227250630730

    Lucas G

    4 months ago

    The second one is just a matter of pasting in the body of the script in a script tag
  • The other one you need to set the src via an attribute
  • Should just work
  • lucasg-1350090582655242280

    Lucas G

    4 months ago

    Is this how tag manager tags look like now
  • uunicode-1350091847799934997

    unicodes

    4 months ago

    I tried to add the script in this way, or just {src="google url"} and then { window.dataLayer = window.dataLayer [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-4534543543543');}but isn't working for me.
    1350091847887884288-Screenshot_2025-03-14_at_15.01.48.png
  • lucasg-1350092010190798959

    Lucas G

    4 months ago

    1350092009922236486-image.png
  • If you look at the script tag, it's inside the first bracket
  • Meaning it is an attribute
  • Not body
  • uunicode-1350092151387717643

    unicodes

    4 months ago

    Forget about Attributes 😅
  • Now make sense to me 🥰
  • lucasg-1350092327686766662

    Lucas G

    4 months ago

    The other one was likely setup correctly.
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-4534543543543');
  • uunicode-1350092361400713248

    unicodes

    4 months ago

    and in the text editor you just add { window.dataLayer = window.dataLayer [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-4534543543543');} right?
  • Right! Thank you Lucas!
  • This is why Toddle isn't "No Code" but a developer's tool 😅 , you don't have to forget the rules.
  • airmax0640-1358772131369848942

    Airmax

    3 months ago

    Just wanted to share this screen here, as I needed some time to get the analytics and gtag working. hope it helps.
    1358772131386888273-Bildschirmfoto_2025-04-07_um_13.54.13.png
  • uunicode-1358801191772885255

    unicodes

    3 months ago

    Thank you Airmax!