Jump to content

How do I create a hook for Analytics?


Looper

Recommended Posts

Hello, whenever I update WHMCS, all template files are overwritten, causing me to lose my Analytics code each time, and I have to re-add it. I would like to add it using a hook, but I don't know how to write the hook. Could someone please help me? Thanks!

Sample tracking code: 

<script defer src="https://analytics.mysite.xyz/script.js" data-website-id="8777878sad7878fsd5f4sd5f4"></script>

EDIT: i am not using google analytics, i am using umami analytics..

Edited by Looper
Link to comment
Share on other sites

  • Looper changed the title to How do I create a hook for Analytics?
1 hour ago, Looper said:

whenever I update WHMCS, all template files are overwritten

You don't edit the templates that came with it, you create your changes in a template set *based* on that, giving it a new folder.  Updates won't rewrite those, and then you just need to be sure nothing in the new ones needs bringing into the one you made.

Link to comment
Share on other sites

41 minutes ago, bear said:

You don't edit the templates that came with it, you create your changes in a template set *based* on that, giving it a new folder.  Updates won't rewrite those, and then you just need to be sure nothing in the new ones needs bringing into the one you made.

Sorry, but I didn't  get you. 😕  Let me explain how I did it

I edited the Templates > Theme > header.tpl file and added the tracking code under <head>. However, when I update WHMCS  it always gets removed

Link to comment
Share on other sites

In the templates folder, create a new folder "MyTheme" (name is up to you). Copy the theme files in the WHMCS theme you're using into that folder (it only requires the ones you're changing, but all is ok too). So now you have:
Templates > MyTheme > header.tpl and that's where you make changes.
Once you're done, tell WHMCS what theme you want to use (in this case, MyTheme). It will look there first for your files. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated