Tracking + Analytics

Optimize your app with measurement and analysis tools.

Embedding a custom tracking code

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 others who would like to learn more about the Javascript variables available for the Shopgate custom tracking code: please read this article.


Getting started

With the Shopgate custom tracking code feature, you are able to track a wide variety of customer behaviors across selected mobile platforms and 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öbel.de 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, keep reading.

Entering your tracking code

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

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

    TrackingTools.png

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



  3. Enter a title and your tracking code in the script editor. Turn Autovalidation to ON to add extra security and code accuracy to your shop. Your code will be validated before it can be saved.
  4. Click Save.


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

Converting your tracking code into Javascript

Here's 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.
Method:

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 (www.googleadservices.com/pagead/conversion.js)
Method:

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.
com/pagead/conversion.js"
trackingScript.src = "//www.googleadservices.com/pagead/conversion.js";
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.
Method:

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 and 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
Search
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 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 do I 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 Advanced: tracking variables and events.

 

Was this article helpful?
Can't find what you're looking for?
Let us help you—submit a support ticket.
Contact Support