Redeal Script Implementation Guide


How to install the Redeal script

This is an "in detail" description of the Redeal script and how it can be implemented.

For a basic step-by-step instruction on how to perform a standard installation of the Redeal script with Google Tag Manager, please read this guide:


Redeal requires one script to be included called redeal.js and can be included on all pages but the minimum requirement is on landing pages and pages where the Redeal widget should appear.

Redeal has support for different types of triggers for starting referral flows. All use the same script but it is triggered differently. The type of flow is defined by the deal configuration by a tag and the web site must be implemented to support the desired deal tag. If a web page has multiple different deals active at the same time they must be called using different tags.

Any tag names can be used but the standard tags that should be used are:

checkout The script should be loaded and triggered with this after purchase on the order confirmation page (thank you page) by calling the redeal('checkout', {order-information}) function. The function will need order information (defined below) as input and this is used to track conversions of deals. This tag may also trigger a deal to display, defined in Redeal Manager, but it is not necessary.
cornerwidget The corner widget is triggered by calling the redeal('cornerwidget', {prefill-information}) function on any or all landing pages. This will display a button in the edge of the web page which will open a referral flow. The function may recieve prefill information for improved user experience if available on site but it is not necessary.


Note that a Redeal flow is triggered by looking at the domain the page is loaded from. The deal config must match the domain to be active. This means that it is not possible to test the deal from a local development environment or from a server that is addressed with an IP address. If a test environment has a sub domain the configured deal will be triggered but if it is a different domain then the test domain needs to be added to the site configuration separately.

The script should be included on all pages containing a Redeal widget and the desired landing pages and target links defined in the deal.

The landing page URL will contain a parameter ?referer=Redeal that can be used to trigger loading of the script for incoming links. However the script must always be loaded on pages where Redeal should be triggered on site without a link such as the corner widget.

Copy the following code and paste it in the source code directly following the first <body> tag.

(function(i,s,o,g,r,a,m){i['RedealObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window, document, 'script', window.location.protocol + '//', 'redeal');



In order to attribute conversions and optionally trigger the deal widget on the “thanks for your order” / order confirmation page, a call is needed to provide information to Redeal. This call must be added after the script load statement.

total: "113.75",
revenue: "93",
currency: "SEK",
email: "",
coupons: [ "aJ7q54JU" ]

Use properties above where revenue is the total excluding tax and coupons is an array with all codes used in the purchase. Additional fields that may be provided are name and phone which will be used for prefill and contact integrations.


Corner widget

The corner widget is triggered with a simple function call.


Alternatively, if user information is present on the web site it can be sent to the script for prefill of fields in order to improve the user experience. All fields are optional.

email: "",
name: "John Doe",
phone: "999999999"


Target links

For each deal that is configured in Redeal Manager a target link is generated. This link can be used in emails or social media posts to generate traffic to your web site and activate a referral flow.

If target links are distributed by a marketing automation tool that supports personalized tags/variables on send then the link should contain the name and email as: Redeal-Target-Link?email=*|Email|*&name=*|Name|*. This will automatically prefill the name and/or email address automatically. Please refer the marketing automation tool documentation for specific format of variables


Custom trigger tags

To trigger the redeal flows by customer trigger call the redeal(x) function where x is a deal trigger tag defined in the Redeal Manager. For example this can be called using an onclick event:


If multiple action deals are configured with the same trigger tag then the deal will be randomly selected to provide an A/B testing facility. Note that, as with all triggers, the script must have been loaded on the page first for this to work.


Verification of installation

A Chrome plugin is available for verifying the installation. It can be downloaded here

Note: The Chrome plugin will only detect if the script is loaded on the current page so wait until the page is fully loaded.


Example - Order confirmation page script with transaction details

A correctly implemented script for the order confirmation page with transaction details will look like this:

(function(i,s,o,g,r,a,m){i['RedealObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window, document, 'script', window.location.protocol + '//', 'redeal'); redeal('checkout', { total: "113.75", revenue: "93", currency: "SEK", email: "", coupons: [ "aJ7q54JU" ] });


Example - Landing page script with corner widget

A correctly implemented script for landing pages that will also be able to display cornerwidget campaigns will look like this:

(function(i,s,o,g,r,a,m){i['RedealObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window, document, 'script', window.location.protocol + '//', 'redeal'); redeal('cornerwidget');