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

  • uunicode-1348784927423856671

    unicodes

    4 days 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

    1 day ago

    It says “google url
  • uunicode-1350046706896736338

    unicodes

    1 day 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

    1 day 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

    1 day ago

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

    unicodes

    1 day 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

    1 day ago

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

    Lucas G

    1 day 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

    1 day 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

    1 day ago

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

    unicodes

    1 day 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

    1 day 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

    1 day ago

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

    Lucas G

    1 day 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

    1 day 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!
    👍1
  • This is why Toddle isn't "No Code" but a developer's tool 😅 , you don't have to forget the rules.

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.