Retargeting JavaScript Tracking Code

In order for Retargeting to record the necessary events from your site, you have to insert the following JavaScript code right before the closing of <head> tag.

To use Retargeting you need the Tracking API Key from your Retargeting account. The Tracking API Key is automatically generated on account registration.

The add_to_cart_button_id and price_label_id parameters are needed for the mouse over add to cart respectively mouse over product price events which are executed on the product page when a user moves the cursor over the add to cart button and respectively product price element.

This code is loaded asynchronous, which means it won't slow down in any way the page's load time and it will work independently from your application.

setEmail Function

This function needs to be called each time a guest registers, logs in or fills in the email address in a form on the website (e.g. Contact or Newsletter Form).

setEmail Function Parameters

email [required][text]: guest email address

name [optional][text]: guest name

phone [optional][text]: guest phone number

city [optional][text]: guest town

sex [optional][numeric:0/1]: guest sex – This parameter is numeric and has two possible values: 0 – woman and 1 – man

birthday [optional][text]: guest birthday in format DD-MM-YYYY

callback_function [optional][function]: with this parameter you can define a function that will be executed after setEmail's behaviour is finished.

setEmail Function Examples

sendCategory Function

This function must be called when a visitor lands on a category page. sendCategory Function Parameters

id [required][numeric/text]: category id

name [required][text]: category name

parent [required][numeric/text/false]: parent category id (category's parent id). If the category doesn't have a parent category, send false value

breadcrumb [required][array]: array containing all the parent categories of the sent category (in this array you must not add the main category). If the category has no parent category then send an empty array.

Each parent category from the breadcrumb is sent as an object and contains the following properties:

breadcrumb[0].id [required][numeric/text]: category id

breadcrumb[0].name [required][text]: category name

breadcrumb[0].parent [required][numeric/text/false]: parent id category. If there is no parent category then send false value.

callback_function [optional][function]: with this parameter you can define a function that will be executed after sendCategory's behaviour is finished.

sendCategory Function Examples

sendBrand Function

This function must be called every time a visitor lands on a producer/brand page. In this case, the brand page is the page where the brand details are listed, or the page that lists the products belonging to that particular brand. sendBrand Function Parameters

id [required][numeric/text]: brand id

name [required][text]: brand name

callback_function [optional][function]: with this parameter you can define a function that will be executed after sendBrand's behaviour is finished.

sendBrand Function Examples

sendProduct Function

This function must be called every time a visitor lands on a product page (page showing the details of a product).

sendProduct Function Parameters

id [required][numeric/text]: product id

name [required][text]: product name

url [required][text]: URL of the product page

img [required][text]: source (src) of main product image (URL of the image)

price [required][numeric]: product price. If the product is on promotion (price is reduced) then this parameter gets the value of the price before the promotion was applied to the product (old price).

promo [optional][numeric]: promotional price (new price). When the product isn’t on promotion (no reduced price), send value 0.

brand [optional][object/false]: details about product brand. If the product does not belong to any brand, send false value.

The object containing brand details, has the following properties:

brand.id [required][numeric/text]: brand ID

brand.name [required][text]: brand name

category [required][object]: details about product’s category

sendProduct Function Examples

addToCart Function

This function must be called every time a product is added to cart.

If you redirect to another page (e.g. the checkout page) right after the user added the product to cart, your store's add to cart function must be set as the callback function for our addToCart function, so it can execute right after the data has been sent to Retargeting (see the examples of the addToCart function).

If add to cart is possible in other pages too, other than in the product page, you must first call the sendProduct function (for the product that will be added to cart) right before you call the addToCart function (see the examples of the addToCart function).

In the following paragraphs of the addToCart function, we will talk about "variations" of the products. Variation of a product is the product's properties group the user has to choose when he is willing to add a product to cart: color, size, capacity, etc. For example, an online fashion store can set a system based on color and size variations: "Y-32" (yellow color and size 32), "R-XS" (red color and size XS), "M" (size M) etc.

addToCart Function Parameters

id [required][numeric/text]: product id

quantity [required][numeric/text]: product quantity

variation [required][object/false]: object with details about the chosen variation for the product added to cart. If the product does not have variations send false value

The object containing the details of the chosen variation has the following properties:

variation.code [required][text]: unique combination of properties that form the variation of product, separated by dash (-). It is mandatory to use a simple dash (-) to separate the options of variation.

variation.stock [required][bool]: false - out of stock, true - in stock

variation.details [required][object]: object that contains details about each variation option.

Variation details object contains an array of variation properties defined through the code used in the variation code object, and each property is an object containing the following properties:

variation.details.variation_code_option.category_name [required][text]: name of the category of the property

variation.details.variation_code_option.category [required][numeric/text]: unique token or unique id of the category of the property

variation.details.variation_code_option.value [required][text]: full name/value of the variation property (what the user selected)

callback_function [optional][function]: with this parameter you can define a function that will be executed after addToCart's behaviour is finished.

addToCart Function Examples

removeFromCart Function

This function must be called every time a product is removed from cart.

In the following paragraphs of the removeFromCart function, we will talk about "variations" of the products. Variation of a product is the product's properties group the user has to choose when he is willing to remove a product from cart: color, size, capacity, etc. For example, an online fashion store can set a system based on color and size variations: "Y-32" (yellow color and size 32), "R-XS" (red color and size XS), "M" (size M) etc.

removeFromCart function parameters

id [required][numeric/text]: product id

variation [required][object/false]: object with details about the chosen variation for the product added to cart. If the product does not have variations send false value

The object containing the details of the chosen variation has the following properties:

variation.code [required][text]: unique combination of properties that form the variation of product, separated by a dash (-). It is mandatory to use a simple dash (-) to separate the options of variation.

variation.stock [required][bool]: false - out of stock, true - in stock

variation.details [required][object]: object that contains details about each variation option.

Variation details object contains an array of variation properties defined through the code used in the variation code object, and each property is an object containing the following properties:

variation.details.variation_code_option.category_name [required][text]: name of the category of the property

variation.details.variation_code_option.category [required][numeric/text]: unique token or unique id of the category of the property

variation.details.variation_code_option.value [required][text]: full name/value of the variation property (what the user selected)

callback_function [optional][function]: with this parameter you can define a function that will be executed after addToCart's behaviour is finished.

removeFromCart Function Examples

setVariation Function

This function must be called every time when a product variation is selected. It can be seen that the parameters are the same as the ones within the addToCart function.

If the add to cart event is possible in other pages than the product page (implicitly the selection of variation), you must first call the sendProduct function for the product that is being added to cart.

setVariation Function Parameters

id [required][numeric/text]: id of the product for which the variation is selected.

variation [required][object/false]: object with details about the chosen variation for the product added to cart. If the product does not have variations send false value

The object containing the details of the chosen variation has the following properties:

variation.code [required][text]: unique combination of properties that form the variation of product, separated a dash (-). It is mandatory to use a simple dash (-) to separate the options of variation.

variation.stock [required][bool]: false - out of stock, true - in stock

variation.details [required][object]: object that contains details about each variation option.

Variation details object contains an array of variation properties defined through the code used in the variation code object, and each property is an object containing the following properties:

variation.details.variation_code_option.category_name [required][text]: name of the category of the property

variation.details.variation_code_option.category [required][numeric/text]: unique token or unique id of the category of the product

variation.details.variation_code_option.value [required][text]: full name/value of the variation property (what the user selected)

variation.details.variation_stock_option.stock [required][numeric]: if variation is in stock then send the value of 1. When the variation is not in stock send the value of 0.

callback_function [optional][function]: with this parameter you can define a function that will be executed after addToCart's behaviour is finished.

setVariation Function Example

addToWishlist Function

This function must be called every time a product is added to a wishlist. If add to wishlist can be done in pages other than product page, the sendProduct function must be called prior to the calling of the addToWishlist function.

addToWishlist function parameters

id [required][numeric/text]: id of the product added to a wishlist

callback_function [optional][function]: with this parameter you can define a function that will be executed after addToWishlist's behaviour is finished.

addToWishlist Function Examples

clickImage Function

This function must be called every time a visitor opens or clicks the main image of the product in the product page.

clickImage function parameters

id [required][numeric/text]: id of the product the picture belongs to

callback_function [optional][function]: with this parameter you can define a function that will be executed after clickImage's behaviour is finished.

clcikImage Function Examples

commentOnProduct Function

This function must be called every time a visitor submits a product comment or review.

commentOnProduct Function Parameters

id [required][numeric/text]: id of the product for which the comment is added

callback_function [optional][function]: with this parameter you can define a function that will be executed after commentOnProduct's behaviour is finished.

commentOnProduct Function Examples

likeFacebook Function

This function must be called every time a visitor likes (Facebook Like) a product while he is on that specific product's page.

likeFacebook Function Parameters

id [required][numeric/text]: the id of the liked product

callback_function [optional][function]: with this parameter you can define a function that will be executed after likeFacebook's behaviour is finished.

likeFacebook Function Examples

saveOrder Function

This function must be called whenever an order is successfully registered.

For any payment method, the function saveOrder must always be called on the Thank You page (the page where the user is informed that the order was registered). If there is no Thank You page, saveOrder function must be called after the order is successfully stored in the database.

For example, for online payment methods, the saveOrder function must be called after the response from the payment processor is received and the answer is positive (not error or fail). In this case it means the order is successfully registered (was paid). The saveOrder function must be called on the Thank You page, when the whole registration process of the order is over.

saveOrder Function Parameters

order_no [required][numeric/text]: unique number of the order recorded

lastname [optional][text]: name of the buyer

firstname [optional][text]: buyer surname

email [required][text]: e-mail adress of the buyer

phone [optional][text]: phone number of the buyer

state [optional][text]: district adress

city [optional][text]: city adress

address [optional][text]: buyer address

birthday [optional][text]: buyer birthday in format dd-mm-yyyy

discount [optional][numeric/0]: the amount/value by which the total amount was reduced. Note that we are not talking about the discount value (e.g. 10%), but the money amount (e.g. 5$ discount for a 100$ order). If there is no discount applied on the order, send value 0.

discount_code [optional][text]: the discount code used when placing the order. If no discount code was used send a empty String (no character string "").

shipping [optional][numeric/0]: value/amount paid for the shipping (shipping fee). If there is no shipping charge, send value 0.

rebates [optional][numeric/0]: value/amount paid for the rebates. If there is no rebates charge, send value 0.

fees [optional][numeric/0]: value/amount paid for the fees. If there is no fees charge, send value 0.

total [required][numeric/0]: amount/total amount of payment for the order sent. Note that this is the total amount the buyer actually paid, the amount obtained after applying any discount and/or shipping fee.

Products ordered are contained in the second parameter of the function, which is an Array. Details for each product are added in the Array through an object that has the following properties:

products[0].id [required][numeric/text]: product id

products[0].quantity [required][numeric]: quantity ordered

products[0].price [[required][numeric]: unit price of the product (per piece)

products[0].variation_code [required][text]: variation code of sent product – for variation code format and other details see variations from the addToCart functions and setVariation. If the product does not have variation please send a empty String (no character string "")

callback_function [optional][function]: with this parameter you can define a function that will be executed after saveOrder's behaviour is finished.

If a visitor buys the same product, but with two different variations ( one yellow shirt and two red shirts ), they will be sent as two different objects (an object for yellow variation and one object for red variation quantity two, both objects with the same value for the property id).

saveOrder Function Examples

visitHelpPage Function

This function must be called every time a visitor visits one of the Help Pages of the site (e.g. How to order, FAQ, How do I get the products)

visitHelpPage Function Parameters

callback_function [optional][function]: with this parameter you can define a function that will be executed after visitHelpPage's behaviour is finished.

visitHelpPage Function Examples

checkoutIds Function

This function must be called every time a visitor reaches the page where he can add the discount code - checkout/cart page.

checkoutIds Function Parameters

This function takes an array as a parameter, containing all the IDs of the products that the visitor intends to purchase (IDs of all the products from the shopping cart).

product_id [required][numeric/text]: product id

checkoutIds Function Examples

setCartUrl Function

This function saves the url of the cart page.

setCartUrl Function Parameters

The function has only one parameter.

url [required][text]: url of cart page

setCartUrl Function Examples

JSON Product Feed

In order for Retargeting to display only products available in stock you need to create a JSON product feed that returns some information about your products.

Feed File Fields

id [required][string]: product_id. It must match with the one sent via _ra.sendProductInfo.id.

price [required][double]: product_price

promo [required][double]: product_promotional_price

promo_price_end_date [optional][string]: promo_price_end_date. In case you cannot provide the end date of the promotional price, then set this attribute's value to null.

inventory [required][object]

inventory.variation [required][object]

inventory.variation.variation_code_one [optional][boolean]

inventory.variation.variation_code_two [optional][boolean]

user_groups [optional][object/empty array]

user_groups.silver [optional][object]

user_groups.silver.price [optional][double]

user_groups.silver.promo_price [optional][double]

user.groups.silver.promo_price_end_date [optional][string]

user_groups.gold [optional][object]

user_groups.gold.price [optional][double]

user_groups.gold.promo_price [optional][double]

user_groups.gold.promo_price_end_date [optional][string]

product_availability [optional][string]: product_availability

Feed File Examples

Push Notifications Setup Guide

Push notifications are an efficient and easy to use channel to communicate with your website's visitors and greatly increase your revenues.

In order to use our push notifications feature, your website must fully support HTTPS.

How to determine if your site fully supports HTTP?

First of all, your website URL must begin with https:// and display a green padlock icon on the browser's address bar.

Your website must also redirect all http:// requests to https:// requests.

If you meet the above criteria, further proceed the following guidelines.

1. Download and unzip the files

2. Open the manifest.json file with your favourite text editor and change the yourdomain.com with your actual domain.

3. Upload the manifest.json, OneSignalSDKUpdaterWorker and OneSignalSDKWorker files to the top-level root of your site directory. The following URLs should be publicly accessible:

https://yourdomain.com/manifest.json

https://yourdomain.com/OneSignalSDKWorker.js

https://yourdomain.com/OneSignalSDKUpdaterWorker.js

4. Log into your Retargeting.Biz account and change the Site Protocol to HTTPS from Settings -> Push Notifications Settings -> Site Protocol - > Save Settings

That's it! All you have to do know is to customize your automated and manual communications as you think best.

REST API

The REST API gives programmatic access to write and read operations over Retargeting.Biz data.

To use the REST API you need the REST API KEY from your Retargeting account. The API KEY is automatically generated on account registration.

Retargeting REST API Client

You can use the Retargeting REST API Client to implement the REST API on your application.

PHP Client download: Retargeting REST API Client

REST API

The REST API gives programmatic access to write and read operations over Retargeting data.

To use the REST API you need the API KEY and TOKEN from your Retargeting account. The API KEY is autogenerated on account registration.

Retargeting REST API Client

You can use the Retargeting REST API Client to implement the REST API on your application.

PHP Client download: Retargeting REST API Client

REST API: discount/create

Create a new discount code for Retargeting.

Resource URLs

JSON: https://retargeting.biz/api/1.0/discount/create.json

Serial: https://retargeting.biz/api/1.0/discount/create.serial

Parameters

discount_type [required][numeric]:

"fixed" - fixed value

"percentage" - percentage value

"nil" - custom discount code without value (like "Free delivery")

discount_value [required][numeric]: value of discount or the name of discount code if it is "nil"

Request Example Response example

REST API: discount/check

Check a discount code on Retargeting.

Resource URLs

JSON: https://retargeting.biz/api/1.0/discount/check.json

Serial: https://retargeting.biz/api/1.0/discount/check.serial

Parameters

discount_code [required][text]: discount code you want to check

Request Example Response Example

Discount codes feed


	["SAMPLE-CODE-1", "SAMPLE-CODE-2", ...]
		

In order for Retargeting to display discount codes to your visitors, you need, if you don't use our REST API, to generate discount codes in your application and returns them as json.

Request

Retargeting makes a request with the following parameters:

key [POST][required][text]: your Retargeting Key to verify if the requester is valid

type [GET][required][numeric]: 0 - fixed value, 1 - percentage value, 2 - free delivery

value [GET][optional][numeric]: value of discount. When the discount code type is 2, the value is not sent (or is set to 0)

count [GET][required][numeric]: number of discount codes required

The response must be a JSON array which contains the discount codes requested.

Response

	Request:
	
		POST: key=your_retargeting_key
		
		GET: type=0&value=30&count=3
	
	Response (returns 3 discount codes with fixed value 30):
		
		["RTJBSKDD", "9DIEM6DJ", "KFLVEDKG"]
	
	

REST API: order/save

Push an order to Retargeting.

Resource URLs

JSON: https://retargeting.biz/api/1.0/order/save.json

Serial: https://retargeting.biz/api/1.0/order/save.serial

Parameters

order_no [required][numeric/text]: unique number of the order recorded

lastname [optional][text]: name of the buyer

firstname [optional][text]: buyer surname

email [optional][text]: e-mail adress of the buyer

phone [optional][text]: phone number of the buyer

state [optional][text]: district adress

city [optional][text]: city adress

adress [optional][text]: buyer address

discount_code [optional][array]: an array of discount codes used when placing the order. If no discount code was used send a empty String (no character string "").

discount [optional][numeric/0]: the amount/value by which the total amount was reduced. Note that we are not talking about the discount value (e.g. 10%), but the money amount (e.g. 5$ discount for a 100$ order). If there is no discount applied on the order, send value 0.

shipping [optional][numeric/0]: value/amount paid for the shipping (shipping fee). If there is no shipping charge, send value 0.

rebates [optional][numeric/0]: value/amount paid for the rebates. If there is no rebates charge, send value 0.

fees [optional][numeric/0]: value/amount paid for the fees. If there is no fees charge, send value 0.

total [required][numeric/0]: amount/total amount of payment for the order sent. Note that this is the total amount the buyer actually paid, the amount obtained after applying any discount and/or shipping fee.

Products ordered are contained in the second parameter of the function, which is Array type. Details for each product are added in Array through an object that has the following properties:

products[0].id [required][numeric/text]: product ID

products[0].quantity [required][numeric]: quantity ordered

products[0].price [[required][numeric]: unit price of the product (per piece)

products[0].variation_code [required][text]: variation code of sent product – for variation code format and other details see variations addToCart functions and setVariation. If the product does not have variation will send a empty string (no character string "")

Request Example Response Example