Support Center

Converting a Tracking Pixel from HTML to JavaScript

Follow

 

 

Tracking pixels are available on Shopgate.

You can embed a tracking pixel in Javascript on your Shopgate mobile apps and website using the tracking codes function.

 

 

In this article, you will find everything you need to convert a tracking pixel from HTML to Javascript.

 

Topics covered in this article:

  1. What is a tracking pixel?
  2. Converting the pixel into Javascript

 

 

1. What is a tracking pixel?

A tracking pixel, or a 1x1 pixel, is a graphical element that loads when a user visits an app and website. This pixel can track activities that could give you an idea of how your users behave in your mobile shop. By studying user behaviors, you could improve your sales methods to increase sales.

If using such a tracking pixel, you should be able to find an HTML snippet in your tracking code similar to this below:

To use this tracking pixel on your Shopgate mobile apps and website, please convert the code into Javascript.

 

2. Converting the pixel into Javascript

The simple steps and rules to convert your tracking pixel can be found below:

2.1 Removing the <div> tags

The first step is to remove the <div> tags. In this example, the tags are:

<div style="display:inline;"> and </div>

 

2.2 Rewriting the <img> contents

The contents inside the <img ..../> need to be converted into the Javascript style.

In this example, the <img .../> tag and its contents can be broken down into 5 different elements:

  HTML code Convert to Javascript with this code:
1. <img ..../>  var imgtag = document.createElement('img');
2. height="1" imgtag.height = '1';
3. width="1" imgtag.width = '1';
4. style="border-style:none;" imgtag.style = 'border-style:none;';
5. alt="" imgtag.alt = '';
6. src="//googleads.g.doubleclick.net/pagead/
viewthroughconversion/928691177/?value=0"
imgtag.src = '//googleads.g.doubleclick.net/pagead
/viewthroughconversion/928691177/?value=0';

 

The resulting Javascript should look like this:

Now your tracking pixel has been converted from HTML to Javascript.

 

3 Entering your tracking code

After your tracking pixel has been converted, 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.


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

 

  

To learn more about the tracking codes function and all its options, please read Setting up tracking codes for your mobile shop

 

 

Comments