Adding tracking code for services like Google Analytics

Tags: 137 views 0

How to add custom JavaScript code required by for example Google Analytics.

Overview

Many third party services require a tracking code to be inserted on every page of your website to gather statistics or other useful information. This article describes a simple way to do this and how to include any other custom JavaScript you might want to add to all the pages in the User Panel.

Before you begin

Create and activate a custom theme as described in Getting started with a custom theme before proceeding.

The CustomScripts partial

The recommended way to add custom JavaScript is by using the partial _CustomScripts.ascx. This file is included in the Site.master file, making its content available on all of the User Panel pages.

  1. Copy the file Themes\NewDefault\Views\Shared\_CustomScripts.ascx to the same folder within your custom theme’s Themes\MyTheme\Views\Shared\_CustomScripts.ascx.
  2. Add your custom script to the file.
  3. Save the changes.

Your custom script will now be included on every page in the User Panel.

Was this helpful?