NamelessMC

Internet Explorer

Internet Explorer is not supported. Please upgrade to a more modern browser.

Google Analytics gtag.js
Started by Nathanacus

Nathanacus

Nathanacus

Member
Joined
15 Jul 2019
Last Seen
11 Sep 2019
Topics
2
Posts
4

I am running v2-pre6, and am trying to add the Google Analytics gtag.js script to my headers... I found the question asked a while ago here -- https://github.com/NamelessMC/Nameless/issues/1348 -- but when I put the script into my /custom/templates/DefaultRevamp/header.tpl, I get a Smarty Compiler error on the website related to the script. Changing the /Default/header.tpl doesn't do anything.

I assume I'm pasting it into the wrong part of the file -- where should the gtag.js script be added to avoid throwing an error?

Thanks for any help you can give! Apologies in advance if it's a simple fix I overlooked.

Nathanacus · over 4 years ago
Samerton

Samerton

Owner
Joined
30 Mar 2015
Last Seen
19 Apr 2024
Topics
41
Posts
1047

Hi,

You're right in saying the Google Analytics script goes into custom/templates/template/header.tpl, but you might need to add {literal} before and {/literal} after the script.

Samerton · over 4 years ago
Nathanacus

Nathanacus

Member
Joined
15 Jul 2019
Last Seen
11 Sep 2019
Topics
2
Posts
4

EDIT: My bad, your suggestion fixed it. I forgot I had tracking blockers enabled, tried a different browser on a whim and it worked just fine. Thanks for your help!

That got rid of the Smarty Compiler error, but it still doesn't seem to be tracking. This might be getting more into Google territory now, unless you can think of anything else? I tried both /custom/templates/Default/header.tpl and /custom/templates/DefaultRevamp/header.tpl, neither showed any traffic in Analytics. Here's what I have for the DefaultRevamp header file (ID is blocked out as #####), if you're able to notice anything obviously wrong.

EDIT: Having trouble with the code snippet tool, so here's a Pastebin instead: https://pastebin.com/Km53VCza

x1
Nathanacus · over 4 years ago · Last edited: over 4 years ago