Add tracking script


Adding the tracking script

To integrate your website with Galytics.net, you need to update the HTML code of the site you want to track. Insert the Galytics.net tracking script code into the <head> section of your site. Place the script within the <head> ... </head> tags.

The Galytics.net tracking script code will look something like this (your exact token will be shown on the website settings page):

<script id="galytics-script"
        data-token="XXX"
        src="https://galytics.net/js/galytics.js" async defer>
</script>

Where to find your javascript snippet

You can find your javascript snippet by logging into your Galytics.net account. Here, you'll see the list of websites you've added.

Click on the "Settings" icon next to the website you want the snippet for. Then, scroll down to the "Analytics Token" section on the following page.

Alternative javascript snippet

The complete galytics.js script includes all features: page loads, custom events, and session recordings. If you only need page loads and custom events, you can use the slim script instead:

<script id="galytics-script"
        data-token="XXX"
        src="https://galytics.net/js/galytics.slim.js" async defer>
</script>

Manual pageviews

By default, the tracking script initiates a pageview as soon as it loads. It also attaches listeners to the History API, automatically triggering pageviews when history.pushState is used. This functionality suits most websites, but we also provide a manual mode for those who prefer to have complete control over when pageviews are triggered.

<script id="galytics-script"
        data-token="XXX"
        src="https://galytics.net/js/galytics.manual.js" async defer>
</script>

Can I use the same snippet across my domain and subdomain?

Yes, you can use the same Galytics.net snippet on multiple sites and subdomains. However, there are two drawbacks to this approach:

  1. Combined Dashboard: You will have a single dashboard with all the stats combined. You won't be able to see separate dashboards for individual sites.
  2. Identical Page Paths: If you have pages with identical paths on different sites (e.g., example.com/best-page/ and subdomain.example.com/best-page/), these paths will be combined into one entry in the "Top Pages" report, with their stats merged.

{info} There are no limits on the number of websites you can create, so if you want separate stats for each subdomain, feel free to create individual websites for each.