# How to put traffic analytics code?

**URL:** https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320
**Category:** Support
**Created:** [May 24, 2018, 12:24am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320 "2018-05-24T00:24:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![coolstart](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@coolstart](https://meta.discourse.org/u/coolstart)
#### Post date: [May 24, 2018, 12:24am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/1 "2018-05-24T00:24:59Z")

</div>

this is the first time I run website without cpanel so quite nervous for everything I touch..

Where and how can I put google analytics code for discourse?

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [May 24, 2018, 12:40am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/2 "2018-05-24T00:40:52Z")

</div>

Hi,  
You’ll find everything you need at `/admin/site_settings/`

Don’t worry about messing things up, you can revert changes easily.

---

<div class="post-metadata">

### Author: ![coolstart](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@coolstart](https://meta.discourse.org/u/coolstart)
#### Post date: [May 24, 2018, 12:46am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/3 "2018-05-24T00:46:22Z")

</div>

thank you.  
I found ‘ga universal tracking code’  
but what if I wanna put statcounter code?

actually I wanna put both GA and statcounter

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [May 24, 2018, 12:48am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/4 "2018-05-24T00:48:17Z")

</div>

We don’t support statcounter, I’m afraid.

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [May 24, 2018, 12:53am UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/5 "2018-05-24T00:53:15Z")

</div>

However, with some modifications to the statcounter script you should be able to get it to run on each page load, this would probably be your starting point:

> [@How do you force a script to refire on every page load in Discourse?](https://meta.discourse.org/t/how-do-you-force-a-script-to-refire-on-every-page-load-in-discourse/74856/5):
>
> I think you can use the PluginAPI onPageChange function to do what you are looking for. See: [Using the JS API](https://meta.discourse.org/t/using-the-pluginapi-in-site-customizations/41281) Here’s an example function: \<script type="text/discourse-plugin" version="0.8"\> api.onPageChange(() =\>{ randBackground(); }); function randBackground() { $('body').css('background-color', '#'+(Math.random()\*0xFFFFFF\<\<0).toString(16)); } \</script\> Update: If you are looking to apply similar changes to post bodies, see [post #26 below](https://meta.discourse.org/t/how-do-you-force-a-script-to-refire-on-every-page-load-in-discourse/74856/26).

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/how-to-put-traffic-analytics-code/88320/7 "2024-06-08T12:37:29Z")

</div>

This topic was automatically closed after 2207 days. New replies are no longer allowed.
