Custom tracking code

Custom tracking codes are available on Shopgate.

In this article, you will find out how to embed a custom tracking code for your Shopgate apps and mobile website.

 Advanced coders, Javascript developers, and those who would like to learn more about the Javascript variables available for the Shopgate custom tracking code, please read Shopgate Tracking Variables and Events


Getting started

With the Shopgate custom tracking code feature, you are able to track a wide variety of customer behaviors across selected mobile platforms & pages.


What is a custom tracking code?

Generally speaking, a custom tracking code is a piece of tracking code that someone wrote or customized specifically for your shop.

To be more specific, you are using a custom tracking code if...

  • your shop uses a tracking service other than the ones mentioned below, or
  • you have modified the code provided to you from a tracking service mentioned below


Integrated Tracking Services at Shopgate

If you use an original tracking code from these services, please refer to the documentations here.

Google Analytics Google Analytics Universal Google Adwords Adobe Dynamic Tag Management
econda AppsFlyer Facebook Pixel Facebook Analytics for Apps
Affilinet ADCELL Ovisto Criteo
mö eTracker    



The Javascript system

While most tracking services provide HTML tracking codes for easy integration on desktop websites, the Shopgate custom tracking code accepts Javascript only to provide extra security for your apps and mobile website.

To use your HTML tracking code on your mobile shop, follow the next chapter to convert it into Javascript.



Entering your tracking code

After your custom tracking code has been written or converted to Javascript, enter it at your Shopgate Admin:

  1. Click on Settings from the menu bar, then select  Tracking Tools.

  2. Locate the Tracking codes section, select a platform and a page to display the code, and click +Add. Click here to see the available platforms and pages

  3. Enter a title and your tracking code in the script editor. Turn Autovalidation to ON - your code will be validated before it can be saved. Click Save.
     The validation function looks for coding mistakes and provides extra security to your shop. If you run into any validation errors, look here for a few tips.

That's it! You have successfully set up a custom tracking code. Repeat the steps here to enter another code if needed.



Converting your tracking code into Javascript

In this chapter, we would like to show you how to convert your tracking code from HTML to Javascript using this example code written in HTML:


To convert this code, follow the simple steps and rules below: 

Rule 1: The <script ...> and </script> tags should NOT be included

From this:

 In the example, the lines in between the <script> tags are defined as <script type="text/javascript">. This type tells us that the code between the <script ..> and </script> tags is Javascript.

Javascript code within the <script ..>...</script> tags can be converted by simply removing the <script> </script> tags and the comments within the /* .... */.

To this:


Rule 2: External files (src) need to be converted

From this: 
 An external file is defined inside the <script> tag (see code part 3). This code means the file has a source (src) of a javascript (.js) file from the web (

An external file inside the <script> tag can be converted by using the following formular:

  HTML code Convert to Javascript with this code:
1. <script ....>  var trackingScript = document.createElement('script');
2. type="text/javascript" trackingScript.type = "text/javascript";
3. src="//www.googleadservices.
trackingScript.src = "//";
4.   document.getElementsByTagName('body')[0].appendChild(trackingScript);
To this:


Rule 3: Do NOT include the <noscript>...</noscript> tags or anything in between

From this:


 The <noscript> code is simply a fallback of HTML, in case the Javascript code (within the <script>...</script> tags) cannot be executed. They could cause duplicated or misleading tracking results if included. In your Shopgate mobile shop, we make sure that your Javascript code is properly executed.

Code within the <script>...</script> tags can be converted by simply removing everything between the <noscript> </noscript> tags.

To this: 


The result: 


Now you have successfully transformed the code. The final Javascript code should look like this:

For more tips on formatting the code, click here.



Frequently Asked Questions

Which platforms & pages can I track using the custom code?

In the table below are the available platforms and pages you can choose from. You can use a tracking code on any combination of a platform and a page*.

Available Platform Available Page
All platforms

Mobile Website Smartphone
Mobile Website Tablets
Mobile Website Smartphone + Tablets

Native Apps Smartphone
Native Apps Tablets
Native Apps Smartphone + Tablets
All pages
Start Page / Homepage
Product List
Product Detail Page
Shopping Cart
Login / Registration
Checkout Summary
Checkout Success

* The Shopgate custom tracking code system is built on javascript variables. To see a list of available variables, click here.



What are the rules and tips on formatting the custom tracking code?

There are a few things you need to know when you write or modify a tracking code in the Shopgate script editor:

  • If your code contains <script> </script> tags, refer to Rule 1 and Rule 2.
  • If your code contains <noscript> </noscript> tags, refer to Rule 3.
  • Comment a single line with "//", and a paragraph with "/* */".
  • Press CTRL+Space to show a list of Shopgate variables available on the page selected for this tracking code.



How to convert a tracking pixel to Javascript?

You are using a tracking pixel if you see an HTML snippet similar to this in your tracking code:

To convert the tracking pixel, read Converting a Tracking Pixel from HTML to JavaScript



To learn more about the tracking code functions and options, please read Shopgate Tracking Variables and Events.


Was this article helpful?
1 out of 1 found this helpful