Belchertown - Adding Matomo Analytics script

199 views
Skip to first unread message

Seth Ratner

unread,
Sep 10, 2022, 12:32:17 AM9/10/22
to weewx-user
Hey everyone,

Has anyone come up with the best way to add a tracking script such that all pages will have it?

I've tried using the .inc files Belchertown supports, but that only tracks the homepage. The header or footer seems like the most obvious solution, but I'm not sure how to make it work.

Thanks,
Seth

vince

unread,
Sep 10, 2022, 1:02:35 PM9/10/22
to weewx-user
Quick look at the header's tmpl file seems to indicate you can add something there similar to the Google Analytics code that is there...

Seth Ratner

unread,
Sep 11, 2022, 12:03:02 PM9/11/22
to weewx-user
Looks like the answer was to create 'header.inc' and put the code there. Oddly, page-header.inc is another option but doesn't seem to work. 

Thanks for pointing me to header.html.tmpl, it had 

#if os.path.exists("header.inc")
        #include "header.inc"
        #end if

Which pointed me to creating header.inc with the desired tracking code. 

Mitchell Tuckness

unread,
Oct 15, 2022, 7:53:45 PM10/15/22
to weewx-user
I am not much of a HTML guru; most of the time, I can muddle through to get stuff working. Can I ask how I get the Belchertown skin to notice the header.inc? I looked at the header.html.tmpl and I see a section that I believe is where I input my analytics information. I guess my question is, do I just take the header.html.tmpl and make a copy in the Belchertown folder called header.inc and add my analytics ID? Do I modify anything else in the file? It seems to have a lot of stuff, and I don't want to mess other stuff up on the site, but I assume somewhere in the skin.conf or something you have to tell it there is a header.inc?

Thanks!

vince

unread,
Oct 15, 2022, 8:11:59 PM10/15/22
to weewx-user
Looking in header.html.tmpl, it includes header.inc if one exists, so you shouldn't need to do anything other than make the file exist and be readable to the webserver.

Give it a try.  You can't break anything if you add a file with 'hello world' or something in there as a test.

Seth Ratner

unread,
Oct 15, 2022, 8:30:04 PM10/15/22
to weewx...@googlegroups.com
header.html.tmpl has code to look for header.inc, and if it exists, include the contents.

So just put the analytics script into a new file called header.inc and that should do it.

If you are just using Google analytics, the it goes in the configuration (skin.conf), no new files needed.

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/aBWNJ_VJqIA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/31b9cfd9-992b-4378-967e-862dbb2ad716n%40googlegroups.com.

purc...@maladomini.com

unread,
Oct 15, 2022, 8:36:48 PM10/15/22
to weewx...@googlegroups.com

Okay, that makes sense. I will create that file and apply it.

 

“If you are just using Google analytics, the it goes in the configuration (skin.conf), no new files needed.”

So I thought that as well. I put the number in it, but it doesn’t work. My analytics dashboard still says it hasn’t communicated, and it’s been months. So I am not sure why not, but I was hoping that I would put it in this header.inc file would solve it for me.

Thank you, I am creating the file and putting it in there. I assume I plop it in the root of the webpage directory.

 

Thanks!

purc...@maladomini.com

unread,
Oct 16, 2022, 12:08:42 AM10/16/22
to weewx...@googlegroups.com

So, to clarify, the header.html.tmpl is a used file and not just a template file? I created a header.inc file and put

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of Seth Ratner
Sent: Saturday, October 15, 2022 6:30 PM
To: weewx...@googlegroups.com
Subject: Re: [weewx-user] Re: Belchertown - Adding Matomo Analytics script

 

header.html.tmpl has code to look for header.inc, and if it exists, include the contents.

Reply all
Reply to author
Forward
0 new messages