Conversion Tracking

Integrate with Tradedoubler's industry leading tracking technology.

Overview

Tradedoubler's tracking technology allows you to track and reward publisher activity in a way that suits you. You can:

  • Track and award commission on an event, product category or individual product level.
  • Control commission attribution and stop voucher code misuse with voucher code tracking.
  • Send tracking data to Tradedoubler without any tracking tags or pixels on your website.
  • Automate your transaction validation process (transaction approval and deletion).

All these features are supported by Tradedoubler's global performance tracking platform. We'll use latency load balancing technology to ensure traffic is routed through the best data centre from anywhere in the world.

Once tracked every transaction then passes through Tradedoubler's proprietary tracking validation process. Impressions, clicks, leads and sales are all screened by dozens of quality checks to confirm their validity. So you can be confident in the accuracy of transactions being reported.


Do not have an affiliate program with Tradedoubler? Contact us

1st party tracking

Tradedoubler is using 1st party data to attribute conversions for over 15 years. This attribution method is the most accurate way of connecting specific events on your website with their respective sources. Using our First Party Cookie Validation, that relies on the storage of a Tradedoubler Unique Identifier (TDUID) on the client domain level, all advertisers and the connected publishers will be able to see an immediate growth of their tracked conversions, thanks to the increased reliability of the tracking setup

Cookieless Tracking

Our cookieless tracking solution ensures that all online journeys are accurately tracked, even when a cookie is not present. This ensures that we are able to provide a complete, accurate and reliable picture of all online journeys leading up to a sale.

  1. Accurate tracking across all internet connected devices, without the use of cookies.

  2. Device fingerprint created without using personally identifiable information.

  3. Automatically active across our publisher network.

  4. Easy implementation for advertisers.

Cross Device Tracking

Tradedoubler's Cross Device Tracking allows you to track user activity (clicks, leads and sales) across their multiple devices. Using deterministic matching (first party data) Tradedoubler matches devices to a user and creates an anonymous profile. Benefits include:

  1. Correct attribution of conversions to devices, publishers and marketing channels.

  2. Track user activity across environment - desktop web, mobile web and in-app.

  3. Accurate understanding of how your digital marketing budget is performing across devices and channels.

  4. Privacy-compliant matching and tracking techniques that protect user data.

Transaction validation

Customers returning goods or cancelling orders? Automate your transaction validation now and save time and money. To suite your needs Tradedoubler offers different ways of automating this process:

Voucher Code Tracking

As well as providing a voucher code distribution system Tradedoubler also offers voucher code tracking - allowing you to report what codes are used for each transaction. This provides three powerful benefits:

  1. Visibility in reports: Reported voucher codes are displayed alongside transactions in the standard reports. This enables advertisers and publisher to analyse the performance of specific codes. If you use exclusive codes for specific publishers, promotions, ad slots, etc. then you can now see their impact on conversion.

  2. Control commission attribution: Exclusive voucher codes can be easily attributed to one or many specific publisher site IDs. When a transaction is reported together with a voucher code Tradedoubler's proprietary validation tests will check if the publishing generating the transaction was allowed to use the code. If not, the transaction can be invalidated or reassigned to the correct publisher. That means you no longer have to battle voucher code theft across your performance marketing.

  3. Link offline to online: Linking a voucher code to a specific publisher site ID means we no longer need a click or impression to know who to assign transactions to. Without the need for a click or impression we are no longer tied to an internet-connected device so the exclusive voucher code can be used in print, radio, TV, etc. When the user completes the transaction online and advertiser reports it to Tradedoubler, the link will be made and the commission assigned to the correct publisher.

Tradedoubler also offers a voucher code distribution system. Check out Vouchers Open API for more information.

Extend transaction lifetime

Your program can be set up to use pending periods, meaning all transactions will remain 'pending' for a set period of time after they are tracked. The pending period typically reflects the advertiser's returns policy, allowing them to amend or deny transactions before they are invoiced. Examples include a user cancelling the order, returning part of the order or payment being rejected. In these scenarios the advertiser will need to amend or deny the transaction in Tradedoubler's system.

The standard pending functionality works on an event ID level, meaning the same pending period is applied to all transactions under an event ID. In some scenarios it is preferable to set the pending period on a transaction level instead. For example:

  • Travel - It is typical to approve transactions once the user has completed their stay at the hotel, taken the flight, returned the hire car, etc. Users could be booking flights, hotels, holidays and car hire just hours in advance or for many months in the future.
  • Insurance/Finance - Users are often required to honour their contract for a minimum amount of time before it is considered an approved transaction.
  • Telecoms - Different mobile devices and contracts can become profitable for the advertiser at different times.

The validOn parameter in the tracking pixel allows you to enter the date when the transaction should become approved. You only need to tell Tradedoubler about transactions that need to be amended or denied before the Valid On date is reached. All other transactions will be automatically approved on the Valid On date.

Individual Product Information

The reportInfo parameter in the tracking pixel allows advertisers to report product data for each transaction. The standard implementation includes product ID, product name, product price and quantity purchased. This information is then visible for advertisers and publishers in the standard reports.

For the ability to award commission and set up promotional pricing on product level see the Product Level Tracking section.

Standard Set-up

Follow this step by step guide to quickly enable the most robust Tradedoubler conversion attribution on your website. Tracking and attribution is the core of our business, and we continue to invest in our tracking technology.

Tracking Library

Tradedoubler's Tracking library is a small and powerful JavaScript toolkit that is designed to help you implement our cutting-edge event attribution technology on your website. It should be executed unconditionally on all of you pages making it easy to manage and scale it to suit your needs. The toolkit does not track any action unless it is directly instructed by you, so it is safe to use in accordance with privacy considerations. The sole purpose of this tool is to let you manage your transaction attribution and get insights on which partners deliver quality traffic to your website.

Tracking Library features include:

  1. Conditionally store Tradedoubler’s unique user ID
  2. Store Tradedoubler’s Strictly Necessary ID to support consented traffic (i.e. cashback/reward partners)
  3. Handle cookie consent and tracking consent
  4. Track on-line events in real time
  5. Accurately track events even without cookies
  6. Unlock Tradedoublers automated tag management
  7. Trigger server-to-server tags to your partners

Initialise the Tracking Library

To Initialise the Tracking Library place the script on all pages of your website. You will find an example script below. Your individual version might be slightly different as it is tailored to your specific needs, please follow the instructions provided by your Tradedoubler Support representative. The Library takes care of all your conversion tracking needs. It also contains a fallback logic built in to make sure you can always measure your events.

<script type="text/javascript">
/*THIS SCRIPT IS ONLY AN EXAMPLE*/
           (function(c,w,v){function getUrlParameter(e){var t=new RegExp("[\?&]"+e+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))}function setCookie(e,t){var r,n=w.location.host,a=n.substring(n.indexOf("."));(a.match(/\./g).length<2||".co"===a.substring(0,a.indexOf(".",1)))&&(a="."+n),r='domain='+a;var i=new Date,o=i.getTime()+31536e6;i.setTime(o);var c="expires="+i.toUTCString();v.cookie='e'+'='+'t'+';'+'c'+';'+'r'+';path=/;sameSite=none;Secure=true'}var tdclid_sn=getUrlParameter("tdclid_sn");tdclid_sn&&setCookie("tdclid_sn",tdclid_sn);var q='?org='+c.organization+'&prog='+c.programId;w.tdfallback=function(e){var t,r=v.getElementsByTagName("script")[0];(t=v.createElement("script")).src=e+q,r.parentNode.insertBefore(t,r)};
          (function(i,s,o,g,r,a,m){i['TDConversionObject']=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', 'https://sdk.tradedoubler.com/trsdk'+q, 'tdconv'); tdconv('init',c);
          })({organization: '123456', programId: '654321', program: false, element: 'iframe'}, window, document);
/*THIS SCRIPT IS ONLY AN EXAMPLE*/
</script>
							

Note: We strongly recommend placing Tracking Library on your website directly as using Google Tag Manager or other popular script insertion tools might be blocked by tracking prevention mechanisms (Safari, Firefox) as well as ad-blocking software.

Trigger conversion events

When tracking events on your website you need to provide event attributes. Complete list of attributes is available here.

Example Sale tracking event with all attributes included:

<script type="text/javascript">
/*Define the event*/
var TDConversion = { 
        transactionId: '[ORDER_NUMBER]', 
        ordervalue: '[ORDER_VALUE]', 
        currency: '[CURRENCY]', 
        voucher: '[VOUCHER]', 
        event: 123456, 
        eventTime: '2024-04-22%2011:59:59',
        validOn: '2024-12-30',
        cdt: { 
            extId: '[SHA-256_EMAIL_ADDRESS_HASH]', 
            extType: 0 
        },   
        products: [
            {'id': 'ABC/101', 'name': 'Żółta łódź podwodna', 'price': '9.99', 'qty': '1'},
            {'id': 'ABC/102', 'name': 'Yellow submarine', 'price': '9.99', 'qty': '2'}
        ],
        reportInfo: 'f1=ProductID&f2=NameProduct&f3=1&f4=1' 
    }; 
/*Send the data to Tradedoubler*/
tdconv('track', 'sale', TDConversion);
tdfallback('{tradedoubler_provided_value}');
</script>
							

Example Lead tracking event with minimum attributes included:

<script type="text/javascript">
/*Define the event*/
var TDConversion = { 
        transactionId: '[ORDER_NUMBER]', 
        event: 123456
    }; 
/*Send the data to Tradedoubler*/
tdconv('track', 'sale', TDConversion);
tdfallback('{tradedoubler_provided_value}');
</script>
							

Available event attributes:

Name Description Type Required?
transactionId Your unique reference for the transaction taking place. This must be unique for each transaction and should ideally match your internal reference. String Yes
event The event ID for the lead/sale taking place as provided by Tradedoubbler. If you are only using one event ID on your program this can be hard-coded. If you are using multiple event IDs you must ensure the correct event ID is used. Integer Yes
ordervalue The order value for the transaction. You must decide if you include tax (e.g. VAT) and shipping or just the net order value. No currency symbols (e.g. £) or thousand separators should be included. Only a decimal point can be used as a separator. Float (two decimal places only) Yes (for sales)
currency If you work with multiple currencies you can state the currency used and Tradedoubler will convert the order value to your program's currency. The value must be a recognised currency code as per ISO-4217. String No
voucher If you are using Tradedoubler's voucher code tracking feature insert the voucher code used on the transaction. See Voucher Code Tracking for more information. String No
eventTime In case the request is not triggered in real time (for example Server to Server implementation) you can specify the correct event timestamp. Correct format: YYYY-MM-DD hh:mi:ss i.e.: 2020-01-01%2023:59:59 (where whitespace is url encoded %20). Datetime No
cdt Parent of extId and extType. No
extId The user's email address. The value must be hashed using SHA-256 before being included in the tracking pixel/batch file (see Example hash scripts for more information). String No
extType Defines the user ID type. If you are supplying the user's email address then exttype=1. If you are supplying an internal user ID then exttype=0. String No
products Includes the basket details. Is used to create reportInfo parameter to see these details in your Tradedoubler reports. Can be used to easily access the values programatically and use with Tradedoublers versatile Container Tag. Expected structure is:
products: [
{'id': '101', 'name': 'Product-1', 'price': '0.99', 'qty': '1'},
{'id': '102', 'name': 'Product-2', 'price': '9.99', 'qty': '2'}
]
							
Array No
reportInfo Include the basket details in the reportInfo parameter to see these details in your Tradedoubler reports. The value of the parameter must be UTF-8 encoded. If included, this parameter must be placed at the end of the pixel (i.e. the last parameter).

f1 = product ID
f2 = product name
f3 = product price
f4 = quantity ordered

Use URL encoding and concatenate the name=value pairs into one string. Use "&" (ampersand) to separate properties and "|" (pipe) to separate products. For example:
f1=12345&f2=Product Y&f3=10.99&f4=3|f1=67890&f2=Product Z&f3=1000.00&f4=1

See Product Information for more information.
f1 = String
f2 = String
f3 = Double
f4 = Integer
No

Custom Tracking Integrations

We strongly recommend the easy set-up guide. Follow any of the instructions below only when directly instructed by your Tradedoubler support representative.

Pixel Tracking

Pixel tracking is the most common type of tracking as it is quick to implement and provides instant data for advertisers and publishers. It is our preferred tracking method and we would recommend it wherever possible. It consists of two elements:

  1. Redirect page: All Tradedoubler traffic will pass through this page before directing the user onto the requested page on your site. This page will handle Tradedoubler's unique tracking identifier (TDUID) and cookie setting tasks.
  2. Confirmation page: The tracking pixel (also known as the tracking or conversion tag) must be displayed on the confirmation page. This is the page immediately after the transaction has been completed (e.g. confirming the order has been placed).

Redirect Page

You can find redirect scripts in various programming languages in the Example redirect scripts section. This section explains what the script does and highlights any changes you may need to make.

The redirect page is a core part of Tradedoubler's tracking as it removes the reliance on third party cookies. The redirect page sets the data on your domain in a first party cookie. This provides a very secure tracking process without the risk on untracked sales caused by cookie blocking.

The redirect page is a simple script that you must host on your domain. We suggest naming the page redirect or td_redirect. When the page is live you must send the URL to your Tradedoubler contact so we can update the program's tracking settings.

All traffic will be sent to this page with two parameters in the URL:

  1. TDUID: Tradedoubler's unique identifier. Used for matching impressions/cicks with leads/sales.
  2. URL: This is the destination that the user/ad requested to be sent to.

You can also include custom parameters (e.g. site analytics information) on all links, which can be collected on the redirect page and used as you require. If you are using a third party tracking provider (e.g. DoubleClick or Atlas) you can pass the TDUID in a custom parameter so it can be inserted into the tracking pixel later. Speak to your Tradedoubler contact if this is needed.

The inbound link will look something like this:

http://www.domain.com/td_redirect?tduid=489edf2b468ca1b0367f8d0bbf6ab611&url=http://www.domain.com/prod?id=219


Storing the TDUID

The TDUID will be stored as follows:

  1. Persistent cookie: Set to expire after one year from today's date (the cookie window will be managed from Tradedoubler's system). The cookie must be named TRADEDOUBLER.
  2. Session variable: Set to expire once the session has ended. We suggest naming the variable TRADEDOUBLER for consistency.
Note: If the checkout and order confirmation is handled on a subdomain (e.g. checkout.domain.com) you must make sure the cookie is set so that it can be accessed by all subdomains (i.e. on domain.com rather than www.domain.com).

Some examples of how to achieve this are:

PHP setcookie("TRADEDOUBLER", $tduid, time()+3600*24*365, "/", ".domain.com")
ASP Response.Cookies("TRADEDOUBLER").Domain = ".domain.com"


Redirecting the user

If there is a destination URL included in the inbound link the script will collect this and forward the user to the requested page. If the URL is empty then the user will be sent to your site's default URL.

The redirect script you receive from Tradedoubler will have the default URL set to http://www.domain.com. You must change this to your default landing page (normally your site homepage).

If your site requires URLs to be encoded please notify your Tradedoubler contact. They will change the program settings so that the URL parameter is UTF-8 encoded like so:

...url=http%3A//domain.com/prod%3Fid%3D219


Direct Linking

It is possible to handle these tasks without the use of a redirect page. Your Tradedoubler contact can change the program settings to send users direct to the requested URL (e.g. a specific product page).

If this option is implemented then you must use a script to handle the cookie and session variable setting on ALL pages on your site. This should be a standard module used on all page loads so that it is not missed when new pages are created.

To achieve this you can use the redirect page script and remove the section handling the redirect.

Confirmation Page

The confirmation page is the page directly after the payment has been processed. It will typically confirm to the user that the order has been placed. This page needs to contain Tradedoubler's tracking pixel in order for the order details to be tracked.

The tracking pixel should be placed as high on the confirmation page as possible to ensure it loads successfully. We suggest immediately after the opening <body> tag.

You can find scripts in various programming languages in the Example pixel tracking scripts section. They show how to collect the required values and construct the tracking pixel. Below are examples of how the final tracking pixel will look for leads and sales.

A standard sale tracking pixel looks like this:

<iframe src="https://tbs.tradedoubler.com/report?organization=12345&event=12345&orderNumber=12345&orderValue=10.99&currency=EUR&tduid=e0f15774d8d148963fd2df1bf9396d54&type=iframe&voucher=SALEXMAS2014&validOn=2015-01-30&checksum=v0444fb650f3d10e030c973f73bcacb9b51&extid=f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a&exttype=1&reportInfo=f1%3DProdNr01%26f2%3DProdName1%26f3%3D100.00%26f4%3D2&event_time=2020-01-01%2023:59:59&cons=false" frameborder="0" width="1" height="1"></iframe>

A standard lead tracking pixel looks like this:

<iframe src="https://tbl.tradedoubler.com/report?organization=12345&event=12345&leadNumber=12345&tduid=e0f15774d8d148963fd2df1bf9396d54&extid=f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a&exttype=1&type=iframe&checksum=v0444fb650f3d10e030c973f73bcacb9b51&event_time=2020-01-01%2023:59:59&cons=false" frameborder="0" width="1" height="1"></iframe>

Note: tbs.tradedoubler.com is used for sales and tbl.tradedoubler.com is used for leads.
Note: The extid value in these examples uses the email address test@test.com. You must replace the value with a valid extid before setting it live on your site. If a valid extid is not available you should leave it completely empty (e.g. extid=&exttype=1).
Note: If you are using server-to-server communication (rather than placing the pixel on the confirmation page) the URL stucture is the same as the pixel described above, with one exception. You must remove the type=iframe from the URL.

Pixel parameters

The tracking pixel can contain the following parameters.

Name Description Type Required?
organization Your organization ID as provided by Tradedoubler Integer Yes
event The event ID for the lead/sale taking place as provided by Tradedoubbler. If you are only using one event ID on your program this can be hard-coded. If you are using multiple event IDs you must ensure the correct event ID is used. Integer Yes
leadNumber/ orderNumber Your unique reference for the transaction taking place. This must be unique for each transaction and should ideally match your internal reference. String Yes
orderValue The order value for the transaction. You must decide if you include tax (e.g. VAT) and shipping or just the net order value. No currency symbols (e.g. £) or thousand separators should be included. Only a decimal point can be used as a separator. Float (two decimal places only) Yes (for sales)
currency If you work with multiple currencies you can state the currency used and Tradedoubler will convert the order value to your program's currency. The value must be a recognised currency code as per ISO-4217. String No
tduid Tradedoubler's unique tracking ID that was set in a cookie and session variable by the redirect page. It should be collected from the cookie or session variable. String Yes
extid The user's email address. The value must be hashed using SHA-256 before being included in the tracking pixel/batch file (see Example hash scripts for more information). String No
exttype Defines the user ID type. If you are supplying the user's email address then exttype=1. If you are supplying an internal user ID then exttype=0. Integer No
type Sets the pixel type as iFrame. String Yes
voucher If you are using Tradedoubler's voucher code tracking feature insert the voucher code used on the transaction. See Voucher Code Tracking for more information. String No
validOn The value must use the format YYYY-MM-DD (as per ISO-8601). Other formats will break the tracking pixel of be handled incorrectly. See Valid On for more information. Date (YYYY-MM-DD) No
checksum This is part of Tradedoubler's fraud protection measures and we highly recommend you implement it. Your Tradedoubler contact will explain how it should be implemented. String No
reportInfo Include the basket details in the reportInfo parameter to see these details in your Tradedoubler reports. The value of the parameter must be UTF-8 encoded. If included, this parameter must be placed at the end of the pixel (i.e. the last parameter).

f1 = product ID
f2 = product name
f3 = product price
f4 = quantity ordered

Use URL encoding and concatenate the name=value pairs into one string. Use "&" (ampersand) to separate properties and "|" (pipe) to separate products. For example:
f1=12345&f2=Product Y&f3=10.99&f4=3|f1=67890&f2=Product Z&f3=1000.00&f4=1

See Product Information for more information.
f1 = String
f2 = String
f3 = Double
f4 = Integer
No
event_time In case the request is not triggered in real time (for example Server to Server implementation) you can specify the correct event timestamp. Correct format: YYYY-MM-DD hh:mi:ss i.e.: 2020-01-01%2023:59:59 (where whitespace is url encoded %20). Datetime No
cons Cookie consent parameter. In case user doesn't consent to 3rd party cookies set this parameter value to "false". If the value is not provided or otherwise different Tradedoubler will assume the consent was granted. Bool No
Note: The organization ID can be replaced by a program ID and publisher site ID combination if required. Your Tradedoubler contact can explain this further.

Testing the implementation

Every implementation needs to be tested to verify that the tracking is working correctly. Once you have implemented the redirect page and pixel tracking get in touch with your Tradedoubler contact, who will provide you with a test link.

Before each test make sure you clear your cookies and internet cache to ensure the test results are accurate.

Follow these steps for each test:

  1. Clear your cookies and internet cache.
  2. Click on the test link. You should be redirected to the default URL specified in the redirect page (usually your site homepage).
  3. Perform a transaction (lead or sale).
  4. You should end up on the confirmation page. Select 'view page source' (or your browser's equivalent).
  5. Search for tbl.tradedoubler.com or tbs.tradedoubler.com (depending on whether you are a tracking a lead or sale). Copy the full URL (tracking pixel).
  6. Log in to your Tradedoubler account and select Financial/Check Implementation from the menu system.
  7. Follow the steps on this page to test the implementation.
    • Choose program: Choose which program you want to test.
    • Choose event type: Choose which event you want to test.
    • Enter trackback URL: Enter the URL (tracking pixel) you copied from your confirmation source code.
    • Tick the boxes to confirm you have completed the checks.

If the trackback is not correctly implemented you will get a detailed error message that indicates which part of the implementation is not functioning properly.

You can also check the 'lead/sale breakdown report' to confirm that the test tracked successfully. It can take between 10 and 45 minutes for transactions to appear in the reports.


Note: Step two will test the session parameter tracking. To test the cookie tracking you should instead click through the test link, close your browser, open a new browser window and go directly to your site (not using a Tradedoubler link). Then continue from step three to complete the rest of the test.
Note: If you are implementing tracking across a number of countries your Tradedoubler contact will provide you with test links for each country. It is important you test the implementation for each country to ensure there are no mistakes with the tracking code, redirect page, event IDs, etc.

Product Level Tracking

Product Level Tracking uses the same user journey described in the Pixel Tracking section, but the tracking pixel is different. This section covers the PLT tracking pixel only - you still need to implement the redirect page as described in the redirect page section and conduct testing as described in the testing section.

You can find scripts in various programming languages in the Example PLT scripts section. They show how to collect the required values and construct the tracking pixel. Below is an example of how the final tracking pixel will look.


This is an example PLT sales tracking pixel for an order consisting of one iPod Nano worth £100 and two iPhones worth £300 each:

<iframe src="https://tbs.tradedoubler.com/report?o(12345)event(51)ordnum(11821909)curr(GBP)chksum(v0477007e101263751dba5148752ac9eb9d)tduid(2ce09b3278da9e51434039b6687d4117)extid(f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a)exttype(1)type(iframe)voucher(SALEXMAS2014)enc(3)basket(pr(i(AB453%2D435)n(Ipod%20Nano%202gb)gr(25)v(100)q(1))pr(i(AD455%2D425)n(IPhone%2016gb)gr(46)v(300)q(2)))event_time(2020-01-01%2023:59:59)cons(false)" frameborder="0" width="1" height="1"></iframe>

Pixel parameters

The tracking pixel can contain the following parameters:

Name Description Type Required?
o Your organization ID as provided by Tradedoubler Integer Yes
event Defines tracking settings in Tradedoubler's system. Provided by Tradedoubler. Integer Yes
ordnum Your unique reference for the transaction taking place. This must be unique for each transaction and should ideally match your internal reference. String Yes
curr If you work with multiple currencies you can state the currency used and Tradedoubler will convert the order value to your program's currency. The value must be a recognised currency code as per ISO-4217. String No
chksum This is part of Tradedoubler's fraud protection measures and we highly recommend you implement it. Your Tradedoubler contact will explain how it should be implemented. String No
tduid Tradedoubler's unique tracking ID that was set in a cookie and session variable by the redirect page. It should be collected from the cookie or session variable. String Yes
extid The user's email address. The value must be hashed using SHA-256 before being included in the tracking pixel/batch file (see Example hash scripts for more information). String No
exttype Defines the user ID type. If you are supplying the user's email address then exttype=1. If you are supplying an internal user ID then exttype=0. Integer No
type Sets the pixel type as iFrame. String Yes
voucher If you are using Tradedoubler's voucher code tracking feature insert the voucher code used on the transaction. See Voucher Code Tracking for more information. String No
enc Defines the encoding used for i and n values in the basket. Use the appropriate number from below (i.e. enc(4) if using UTF_16):
0 = Cp1252
1 = ISO_8859_1
2 = ISO_8859_15
3 = UTF_8
4 = UTF_16
5 = ISO_8859_4
6 = ISO_8859_2
Integer Yes
basket Used to capture product data for the transaction. See specific sub-parameters below. N/A - parent parameter Yes
pr(...) Product row, used to hold information for each product within the basket. N/A - parent parameter Yes
gr(...) Product group ID as provided by Tradedoubler. Used to distinguish different product categories. Integer Yes
i(...) Your unique reference for the product being purchased (i.e. SKU, Product_ID, etc.).

The maximum string length is 20 characters and it can only contain alphanumerics, hyphen, underscore and decimal point:
[0-9][a-z][A-Z]-_.

The value must be encoded and match the format selected in the enc() parameter above.
String Yes
n(...) The name of the product being purchased. The maximum string length is 20 characters and the value must be encoded, matching the format selected in the enc() parameter above. String Yes
v(...) The value of the product being purchased (per item). For example, if two of the same product are being purchased you should state the price of the single product in this parameter (the q parameter would state that two products were purchased).

No currency symbols (e.g. £) or thousand separators should be included. Only a decimal point can be used as a separator.
Float (two decimal places only) Yes
q(...) Quantity of the product being purchased. Defaults to one if not supplied. Integer Yes
event_time In case the request is not triggered in real time (for example Server to Server implementation) you can specify the correct event timestamp. Correct format: YYYY-MM-DD hh:mi:ss i.e.: 2020-01-01%2023:59:59 (where whitespace is url encoded %20). Datetime No
cons Cookie consent parameter. In case user doesn't consent to 3rd party cookies set this parameter value to "false". If the value is not provided or otherwise different Tradedoubler will assume the consent was granted. Bool No
Note: Valid On is not currently supported in PLT.
Note: The extid value in these examples uses the email address test@test.com. You must replace the value with a valid extid before setting it live on your site. If a valid extid is not available you should leave it completely empty (e.g. extid=&exttype=1).

Offline Tracking

Offline tracking uses the same user journey described in the Pixel Tracking section, but the transfer of conversion data to Tradedoubler is different. This section covers the post-conversion steps only - you still need to implement the redirect page as described in the redirect page section.

Storing the TDUID

The redirect page will have saved the TDUID in a session variable and cookie. When the transaction has taken place the TDUID must be collected from the session variable or cookie. Your Tradedoubler contact can provide code examples of how to achieve this.

Once the TDUID has been collected it needs to be stored in your database and linked to the transaction details. These will be collected and entered into a batch file in the next section.

Generating the XML file

On a regular basis you will need to generate a file with details of all conversions (leads and/or sales) and send it to Tradedoubler. The frequency of the file will differ depending on your business needs (i.e. daily, weekly or monthly), however we suggest you produce it as regularly as possible. This ensures there is regular data available for advertisers, publishers and Tradedoubler to analyse, review program performance and identify potential problems early.

The XML file must be saved using the following naming convention: standard_OrganizationId_SequenceId.xml. For example, standard_12345_1.xml would be used for the first file generated for organisation ID 12345.

The XML file will include the same parameters as outlined in the confirmation page section. There are four additional parameters for the batch file:

Name Description Type Required?
checksum This is part of Tradedoubler's fraud protection measures and is unique for each file. Your Tradedoubler contact will explain how it should be implemented. String Yes
sequenceNr The sequence number of the batch file being sent. This must be iterated for each file (i.e. 1, 2, 3) and must match the sequence number used in the file name. Integer Yes
numberOfTransactions This must match the total number of transactions in the file. Tradedoubler will compare this value to the number of <transaction></transaction> entries in the file. Integer Yes
timeStamp The timestamp of when the transaction occurred. The timestamp must be formatted as YYYY-MM-DD hh:mm:ss (using a 24 hour clock). For example, 2015-01-30 15:00:30. The program's timezone will be used when importing the transactions. If you wish to use an alternative timezone you can do so as an offset to GMT. For example, 2015-01-30 15:00:30 GMT+3:00 Date Yes

The format for sales is as follows:

<?xml version="1.0"?>
<tradeDoublerStandard>
<checksum>ffd93f16876049265fbaef4da268dd0e</checksum>
<organizationId>12345</organizationId>
<sequenceNr>1</sequenceNr>
<numberOfTransactions>1</numberOfTransactions>
<transactions>
	<transaction>
		<eventId>5</eventId>
		<orderNumber>991235434CD542EF</orderNumber>
		<orderValue>5.10</orderValue>
		<currency>EUR</currency>
		<tduid>ec1f9f8a92729e79ff3019288de86ccd</tduid>
		<timestamp>2014-10-30 16:00:00</timestamp>
		<extid>f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a</extid>
		<exttype>1</exttype>
		<voucher>SALEXMAS2014</voucher>
		<validOn>2014-12-25</validOn>
		<reportInfo>
			<item>
				<productNumber>122ER12</productNumber>
				<productName>carrying bag</productName>
				<price>20.55</price>
				<quantity>2</quantity>
			</item>
			<item>
				<productNumber>127AE10</productNumber>
				<productName>blue shoes</productName>
				<price>125.30</price>
				<quantity>1</quantity>
			</item>
		</reportInfo>
	</transaction>
</transactions>
</tradeDoublerStandard>

The format for leads is as follows:

<?xml version="1.0"?>
<tradeDoublerStandard>
<checksum>ffd93f16876049265fbaef4da268dd0e</checksum>
<organizationId>12345</organizationId>
<sequenceNr>1</sequenceNr>
<numberOfTransactions>1</numberOfTransactions>
<transactions>
	<transaction>
		<eventId>4</eventId>
		<orderNumber>ABC234</orderNumber>
		<tduid>ec1f9f8a92729e79ff3019288de86ccd</tduid>
		<timestamp>2014-10-30 16:00:00</timestamp>
		<extid>f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a</extid>
		<exttype>1</exttype>
	</transaction>
</transactions>
</tradeDoublerStandard>
Note: The batch file size can not exceed 100mb. If you expect the quantity of data to exceed this limit please speak to your Tradedoubler contact.
Note: The extid value in these examples uses the email address test@test.com. You must replace the value with a valid extid before setting it live on your site. If a valid extid is not available you should leave it completely empty (e.g. extid=&exttype=1).

Transferring the file to Tradedoubler

There are three ways of transferring the file to Tradedoubler:

  1. Email to email@batch.tradedoubler.com
  2. Post to an FTP/SFTP server

The choice of transfer method needs to be agreed with your Tradedoubler contact so they can implement the correct program settings.


Email

The batch file should be sent as an attachment on an email. The file should be attached directly and not within a compressed file (e.g. zip file).


FTP/SFTP

The file can be posted on your own FTP server, to which Tradedoubler has read access, or on Tradedoubler's FTP server. If using your own FTP server you will need to send your Tradedoubler contact the host, port, path, username and password. They also need to know how regularly the file will be updated and available for download.

If hosted on Tradedoubler's server you will need to tell your Tradedoubler contact the IP address of where the upload request will originate from (this is for security reasons).

Note: The maximum import frequency is one file per hour.

<html>
<head></head>
<body>
	<form action="https://report.tradedoubler.com/pan/pFileBatchUpload.action?organizationId=XXXXXX&secretCode=YYYYYY"enctype="multipart/form-data" method="post">
	<p>Batch file <input type="file" name="files"><br><input type="submit" value="Send"> <input type="reset"></p>
	</form>
</body>
</html>
Note: The maximum import frequency is one file per hour.

Testing the implementation

Every implementation needs to be tested to verify that the tracking is working correctly. Once you have implemented the redirect page and pixel tracking get in touch with your Tradedoubler contact, who will provide you with a test link.

Before each test make sure you clear your cookies and internet cache to ensure the test results are accurate.

Follow these steps for each test:

  1. Clear your cookies and internet cache.
  2. Click on the test link. You should be redirected to the default URL specified in the redirect page (usually your site homepage).
  3. Perform a transaction (lead or sale). You should end up on the confirmation page.
  4. Check that the data has been saved along with the order in your database.
  5. Generate and transfer the batch file and notify your Tradedoubler contact together with the order number(s).

You can also check the 'lead/sale breakdown report' to confirm that the test tracked successfully. It can take between 10 and 45 minutes for transactions to appear in the reports.


Note: Step two will test the session parameter tracking. To test the cookie tracking you should instead click through the test link, close your browser, open a new browser window and go directly to your site (not using a Tradedoubler link). Then continue from step three to complete the rest of the test.
Note: If you are implementing tracking across a number of countries your Tradedoubler contact will provide you with test links for each country. It is important you test the implementation for each country to ensure there are no mistakes with the tracking code, redirect page, event IDs, etc.

Pending Transactions

All transactions are validated by Tradedoubler's proprietary tracking validation process. Once a transaction has passed these tests it is displayed in advertiser and publisher reports.

Programs can be set up to use pending periods, meaning all transactions will remain 'pending' for a set period of time after they are tracked and visible in reports. The pending period typically reflects the advertiser's returns policy, allowing them to amend or deny transactions before they are invoiced. Examples include a user cancelling the order, returning part of the order or payment being rejected.

Advertisers can automate the process of managing pending transaction validation using an XML batch file. Rather than validating transactions one at a time via the interface, advertisers can send a bulk update on a regular basis (i.e. daily, weekly or monthly).

Generating the XML file

The XML file must be saved using the following naming convention: pending_OrganizationId_SequenceId.xml. For example, pending_12345_1.xml would be used for the first file generated for organisation ID 12345.

You can choose to accept, deny or amend transactions in the batch file, as outlined in the following sections.

An explanation of each parameter can be found in the Pixel Tracking section.


Accepted transactions

To accept a transaction without any amendments use <status>A</status>:

<?xml version="1.0" encoding="UTF-8"?>
<tradeDoublerPending>
<checksum>ffd93f16876049265fbaef4da268dd0e</checksum>
<organizationId>12345</organizationId>
<sequenceNumber>1</sequenceNumber>
<numberOfTransactions>1</numberOfTransactions>
<transactions>
	<transaction>
		<eventId>5</eventId>
		<orderNumber>12345</orderNumber>
		<status>A</status>
							
	</transaction>
</transactions>
</tradeDoublerPending>

Denied transactions

To deny a transaction use <status>D</status>. You will also need to include a <reasonId>:

<?xml version="1.0" encoding="UTF-8"?>
<tradeDoublerPending>
<checksum>ffd93f16876049265fbaef4da268dd0e</checksum>
<organizationId>12345</organizationId>
<sequenceNumber>1</sequenceNumber>
<numberOfTransactions>1</numberOfTransactions>
<transactions>
	<transaction>
		<eventId>5</eventId>
		<orderNumber>12345</orderNumber>
		<status>D</status>
		<reasonId>11</reasonId>
	</transaction>
</transactions>
</tradeDoublerPending>
Note: Reason IDs are predefined and are listed in the Supporting Material section.

Amended transactions

You can amend a transaction's orderValue and reportInfo parameters when approving it if something has changed (e.g. some items were returned). To do so use <status>A</status> and include the updated ordervalue and reportInfo values:

<?xml version="1.0" encoding="UTF-8"?>
<tradeDoublerPending>
<checksum>ffd93f16876049265fbaef4da268dd0e</checksum>
<organizationId>12345</organizationId>
<sequenceNumber>1</sequenceNumber>
<numberOfTransactions>1</numberOfTransactions>
<transactions>
	<transaction>
		<eventId>5</eventId>
		<orderNumber>12345</orderNumber>
		<status>A</status>
		<orderValue>100.20</orderValue>
		<reportInfo>
			<item>
				<productNumber>B12D</productNumber>
				<productName>red shoes</productName>
				<price>100.20</price>
				<quantity>1</quantity>
			</item>
		</reportInfo>
	</transaction>
</transactions>
</tradeDoublerPending>
Note: If the order value has changed because one or more items were returned, reportInfo should only include the remaining items.

XML schemas

XSD files for the input format are available here:

Name File
Pending Sales Validation tradedoubler_pending_validation.xsd

Transferring the file to Tradedoubler

See here for instructions on how to transfer the file to Tradedoubler.

Testing the implementation

Every implementation needs to be tested to verify that the tracking is working correctly. Once you have implemented the pending batch file you will need to complete a test lead/sale so that you have a transaction to update.

If you are using real-time pixel tracking you can follow the testing steps here to complete a test lead/sale. If you are using offline tracking then follow the steps here.

Once you have a test transaction you need to generate the pending batch file and transfer it to Tradedoubler. You can check the 'lead/sale breakdown report' to confirm if the transaction status was updated successfully. It can take between 10 and 45 minutes for transactions updates to be processed.

You can also get in touch with your Tradedoubler contact to check if the test was successful.

Supporting Material

This section includes supporting material and example code for you to use during implementation. All code examples use random IDs and these must be replaced with your IDs, as supplied by Tradedoubler.

Please get in touch with your Tradedoubler contact if you need anything else.

Reason IDs

Below is a list of reason IDs that you can use when denying pending transactions:

IDDescription
6Application/credit check denied
7Fraudulent order/application
8Duplicate/sale accredited to another source
9Order yet to be fulfilled
10Returned goods
11Out of stock
12Unfulfilled payment
13Invalid lead
14Order Cancelled
15Callback number shown
16Insufficient information (applicable only for untracked sales)
17Order not found (applicable only for untracked sales)
18Sale already accredited to publisher (applicable only for untracked sales)
19Voucher incorrectly used
Note: Reason IDs one to five are reserved for use by Tradedoubler.

Currency codes

Below is a list of supported currency codes:

CodeCurrencyCountry
AEDEmirati DirhamUnited Arab Emirates
ANGDutch GuilderNetherlands Antilles
ARSArgentine PesoArgentina
AUDAustralian DollarAustralia
AZNAzerbaijani New ManatAzerbaijan
BAMBosnian Convertible MarkaBosnia and Herzegovina
BGNBulgarian LEVBulgaria
BHDBahraini DinarBahrain
BRLBrazilian RealBrazil
BSDBahamian DollarBahamas
CADCanadian DollarCanada
CHFSwiss FrancSwitzerland
CLPChilean PesoChile
CNYChinese Yuan RenminbiChina
COPColombian PesoColumbia
CRCCosta Rican ColonCosta Rica
CZKCzech KorunaCzech Republic
DKKDanish KroneDenmark
DZDAlgerian DinarAlgeria
EGPEgyptian PoundEgypt
EUREuroAustria, Belgium, Finland, France, Germany, Ireland, Italy, Lithuania, Netherlands, Portugal, Spain
FJDFiji DollarFiji
GBPBritish Pound SterlingGreat Britain
GIPGibraltar PoundGibraltar
HKDHong Kong DollarHong Kong
HRKCroatian KunaCroatia
HUFHungarian ForintHungary
IDRIndonesian RupiahIndonesia
ILSIsreali ShekelIsreal
INRIndian RupeeIndia
ISKIcelandic KronaIceland
JODJordanian DinarJordan
JPYJapanese YenJapan
KRWSouth Korean WonKorea
KWDKuwati DinarKuwait
LKRSri Lanka RupeeSri Lanka
LVLLatvian LatLatvia
MADMoroccan DirhamMorocco
MKDMacedonian DenarMacedonia
MXNMexican PesoMexico
MYRMalaysian RinggitMalaysia
NGNNigerian NairaNigeria
NOKNorwegian KroneNorway
NZDNew Zealand DollarNew Zealand
OMROmani RialOman
PENPeruvian Nuevo SolPeru
PHPPhilippine PesoPhilippines
PLNPolish ZlotyPoland
PYGParaguay GuaraniParaguay
QARQatari RiyalQatar
RONRomanian LeuRomania
RSDSerbian DinarSerbia
RUBRussian RubleRussia
SARSaudi Arabian RiyalSaudi Arabia
SCRSeychellois RupeeSeychelles
SEKSwedish KronaSweden
SGDSingapore DollarSingapore
THBThai BahtThailand
TNDTunisian DinarTunisia
TRYTurkish LiraTurkey
TWDTaiwan New DollarTaiwan
UAHUkrainian HryvniaUkraine
USDUS DollarUnited States
UYUUruguayan PesoUruguay
VEFVenezuelan BolivarVenezuela
VNDVietnamese DongVietnam
XAFCentral African CFA Franc BEACCameroon, Central African Republic, Chad, Republic of the Congo, Equatorial Guinea, Gabon
XPFCFP FrancFrench Polynesia, New Caledonia, Wallis and Futuna
ZARSouth African RandSouth Africa

Hash Function

Data privacy is extremely important so we request that all user IDs (extid) are hashed before being passed to Tradedoubler. We have chosen to use the SHA-256 function for its advanced security features.

Hashing is a one-way process meaning Tradedoubler or other partners can not decrypt the value and will never know the email address/user ID of the user.

Before passing the email address/user ID through the hash function you must ensure:

  1. The value is all in lower case
  2. There is no white space
  3. Any encoding (e.g. special characters) is done using UTF-8


Many programming languages provide built-in library support for SHA-256 hashing. Here are some examples.

Java

The Apache Common Codec offers a built in SHA-256 function in the DigestUtils class as follows:

	public static String sha256Hex(final String data) {
	return Hex.encodeHexString(sha256(data));
	}
	

.NET

The .NET Framework offers a number of built in SHA-256 function in the SHA-256 Class of the System.Security.Cryptography namespace, including C#, C++ and VB.

Example Integration with Google Tag Manager

This section includes examples of how to integrate Tradedoubler's 1st Party tracking within Google Tag Manager. The first stage is capture Tradedoubler’s unique ID and set this value as a 1st party cookie on your website.

To do this in Google Tag Manager is easy:

Set 1st Party Cookie

Simply create a new Custom HTML tag which is set to trigger on all pages for a page view event.
Then enter the below code:

	<script src="//hst.tradedoubler.com/file/47446/landingPageGTM_min.js"></script>
	<script>
		setTduid();
	</script>
This command simply checks the webpage URL to see if a tduid is present and if so set as a cookie on your website. If no tduid is present then the script will not execute.


Set Cookie value as User Defined Variable

Once you have setup the logic to create a first party cookie GTM needs to be access this value and assign into a variable so it can be added to your Tradedoubler Sales Tag.
Create a User Defined Variable using 1st Party Cookie type, the cookie name should be: tduid

Sales Tag

Now you're ready to create your sales tag. Select Tradedoubler Sale Conversion Tag from the default options and alongside our required fields you will see an option: TDUID.


Select the variable you created earlier tduid and this will be automatically added to Tradedoubler Sales Tags.

Example redirect scripts

This section includes redirect scripts in various programming languages as well as a pseudo code version to explain what the code is doing.


Redirect script pseudo code

//set session variable with: name = TRADEDOUBLER and value = (the value of the tduid sent from Tradedoubler)
session.set("TRADEDOUBLER") = request.queryString("tduid");

//set persistent cookie with: name = TRADEDOUBLER and value = (the value of the tduid sent from Tradedoubler)
cookie.set("TRADEDOUBLER") = request.queryString("tduid");

//set cookie expiry to one year from now
cookie.expires = todaysDate+365days;

//Redirect functionality. If a parameter with the name "url" was sent in the request, direct the user to that page.
//If no "url" parameter was sent, direct the user to the default URL.
url = request.queryString("url");
if (url != empty) {
response.redirect(url);
} else {
	response.redirect("http://www.merchant.com/index.html");
}

ASP redirect script

<%
Dim defaultUrl, domain, cookieDomain, url, rawUrl
' Change URL to the default landing page/homepage
defaultUrl = "http://www.example.com/"
'
' The domain under which this script is installed
domain = "example.com"
If Request.QueryString("tduid") <> "" Then
	cookieDomain = "." & domain
	Response.Cookies("TRADEDOUBLER") = Request.QueryString("tduid")
	Response.Cookies("TRADEDOUBLER").Expires = DateAdd("d", 365, Date)
	Response.Cookies("TRADEDOUBLER").Domain = cookieDomain
	Response.Cookies("TRADEDOUBLER").Path = "/"
	'
	' If you do not use the built-in session functionality in ASP, modify
	' the following expression to work with your session handling routines.
	Session("TRADEDOUBLER") = Request.QueryString("tduid")
End If
If Request.QueryString("url") <> "" Then
	rawUrl = Mid(Request.QueryString, _
		InStr(1, Request.QueryString, "url") + 4)
	If Left(rawUrl, 13) = "http%3A%2F%2F" _
	Or Left(rawUrl, 14) = "https%3A%2F%2F" Then
		url = Request.QueryString("url")
	Else
		url = rawUrl
	End If
Else
	url = defaultUrl
End If
Response.Redirect(url)
%>

C# redirect script

<%@Page Language="C#"%><%
// Change URL to the default landing page/homepage
string defaultUrl = "http://www.example.com/";
//
// The domain under which this script is installed
string domain = "example.com";
if (Request.QueryString["tduid"] != null)
{
	string cookieDomain = "." + domain;
	HttpCookie cookie = new HttpCookie("TRADEDOUBLER");
	cookie.Value = Request.QueryString["tduid"];
	cookie.Expires = DateTime.Now.AddDays(365);
	cookie.Domain = cookieDomain;
	cookie.Path = "/";
	Response.Cookies.Add(cookie);
	//
	// If you do not use the built-in session functionality in ASP.NET, modify
	// the following expression to work with your session handling routines.
	Session["TRADEDOUBLER"] = Request.QueryString["tduid"];
}
string url;
if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
{
	System.IO.StringWriter writer = new System.IO.StringWriter();
	url = Request.RawUrl.Substring(Request.RawUrl.IndexOf("url") + 4);
	Server.UrlDecode(url, writer);
	url = writer.ToString();
}
else
{
	url = defaultUrl;
}
Response.Redirect(url);
%>

JavaScript redirect script

<script type="text/javascript">
function setCookie(name, value, expires, path, domain, secure)
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie= name + "=" + escape(value) +
	((expires) ? "; expires=" + expires_date.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function getVar(name)
{
	get_string = document.location.search;
	return_value = '';
	do
	{
		name_index = get_string.indexOf(name + '=');
		if(name_index != -1)
		{
			get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
			end_of_value = get_string.indexOf('&');
			if(end_of_value != -1)
			{
				value = get_string.substr(0, end_of_value);
			}
			else
			{
				value = get_string;
			}
			if(return_value == '' || value == '')
			{
				return_value += value;
			}
			else
			{
				return_value += ', ' + value;
			}
		}
	}
	while(name_index != -1)
	{
		space = return_value.indexOf('+');
	}
	while(space != -1)
	{
		return_value = return_value.substr(0, space) + ' ' + return_value.substr(space + 1, return_value.length);
		space = return_value.indexOf('+');
	}
	return(return_value);
}
function redirTo()
{
	var strReturn = "";
	var strHref = document.location.href;
	if ( strHref.indexOf("&url=") > -1 )
	{
		strReturn = strHref.substr(strHref.indexOf("&url=")+5);
	}
	else
	{
		// Change URL to the default landing page/homepage
		strReturn = "http://www.example.com";
	}
	return strReturn;
}

var mytduid = getVar('tduid');
setCookie('TRADEDOUBLER', mytduid, 365);
window.location = redirTo();
</script>

JSP redirect script

<%
// Change URL to the default landing page/homepage
String defaultUrl = "http://www.example.com/";
//
// The domain under which this script is installed
String domain = "example.com";
if (request.getParameter("tduid") != null &&
!request.getParameter("tduid").equals(""))
{
	Cookie cookie = new Cookie("TRADEDOUBLER", request.getParameter("tduid"));
	cookie.setMaxAge(60 * 60 * 24 * 365);
	cookie.setDomain("." + domain);
	cookie.setPath("/");
	response.addCookie(cookie);

	// If you do not use the built-in session functionality in JSP, modify
	// the following expression to work with your session handling routines.
	session.setAttribute("TRADEDOUBLER", request.getParameter("tduid"));
}
String url = null;
String queryString = request.getQueryString();
if (queryString != null)
{
	int urlIndex = -1;
	urlIndex = queryString.indexOf("url");
	if (urlIndex > -1)
		url = java.net.URLDecoder.decode(queryString.substring(urlIndex + 4),"UTF-8");
}
if (url == null || url.equals(""))
	url = defaultUrl;
response.sendRedirect(url);
%>

Perl redirect script

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
use URI::Escape;
my $query = new CGI;
#
# Default landing page
my $defaultUrl = "http://www.example.com/";
#
# The domain under which this script is installed
my $domain = "affiliatemarketing.de";
#
# Internally used variables, do not change
my $cookie;
my $tduid = "";
my $url = "";
if($query->url_param('tduid') ne "")
{
	my $cookieDomain = "." . $domain;
	$cookie = $query->cookie(-name=>'TRADEDOUBLER',
	-value=>$query->url_param('tduid'),
	-expires=>'+1y',
	-domain=>$cookieDomain);
	#
	# If you do not use your own session management, you need to pass the
	# tduid throughout all links on your page. This is needed, if the user has cookies disabled.
	$tduid="tduid=".$query->url_param('tduid');
}
if ($query->url_param('url') eq "")
{
	$url = $defaultUrl;
}
else
{
	#
	# If the redirect url is always encoded use this
	#$url = uri_unescape($query->url_param('url'));
	#
	# If the redirect url might not be encoded use this
	$url = uri_unescape(substr($ENV{QUERY_STRING},
	index($ENV{QUERY_STRING},'url') + 4));
}
#
# If $url already contains parameters, add the tduid by using & else add the tduid by using ?
if ($url =~ /\?/ && $tduid ne "")
{
	$url = $url . "&" . $tduid;
}
else
{
	$url = $url . "?" . $tduid;
}
print $query->header(-type => 'text/html',
-status => '302',
-location => $url,
-cookie => $cookie);

PHP redirect script

<?php
// Open session for cookie handling
session_start();
//
// Change URL to the default landing page/homepage
$defaultUrl = "http://www.example.com/";
//
// The domain under which this script is installed
$domain = "example.com";
if (!empty($_GET["tduid"]))
{
	$cookieDomain = "." . $domain;
	setcookie("TRADEDOUBLER", $_GET["tduid"], (time() + 3600 * 24 * 365), "/", $cookieDomain);
	//
	// If you do not use the built-in session functionality in PHP, modify
	// the following expression to work with your session handling routines.
	$_SESSION["TRADEDOUBLER"] = $_GET["tduid"];
}
if (empty($_GET["url"]))
	$url = $defaultUrl;
else
	$url = urldecode(substr(strstr($_SERVER["QUERY_STRING"], "url"), 4));
header("Location: " . $url);
?>

VB.NET redirect script

<%@Page Language="VB"%><%
' Change URL to the default landing page/homepage
Dim defaultUrl As String = "http://www.example.com/"
'
' The domain under which this script is installed
Dim domain As String = "example.com"
If Request.QueryString("tduid") <> "" Then
Dim cookieDomain As String = "." & domain
Dim cookie As New HttpCookie("TRADEDOUBLER")
	cookie.Value = Request.QueryString("tduid")
	cookie.Expires = DateTime.Now.AddDays(365)
	cookie.Domain = cookieDomain
	cookie.Path = "/"
	Response.Cookies.Add(cookie)
	'
	' If you do not use the built-in session functionality in ASP.NET, modify
	' the following expression to work with your session handling routines.
	Session("TRADEDOUBLER") = Request.QueryString("tduid")
End If
Dim url As String
If Request.QueryString("url") <> "" Then
	Dim writer As New System.IO.StringWriter
	url = Right(Request.RawUrl, _
	(Len(Request.RawUrl) - InStr(1, Request.RawUrl, "url")) - 3)
	Server.UrlDecode(url, writer)
	url = writer.toString()
Else
	url = defaultUrl
End If
Response.Redirect(url)
%>

Example pixel tracking scripts

This section includes tracking pixel scripts in various programming languages as well as a pseudo code version to explain what the code is doing.


Pixel tracking script pseudo code

//Get the TDUID from the session. The TDUID is provided by Tradedoubler on the redirect URL and is unique per user.
tduid = session.get("TRADEDOUBLER");

//Get the TDUID cookie and override the value from the session if the cookie is found.
if (cookie.get("TRADEDOUBLER") != empty) {
    tduid = cookie.get("TRADEDOUBLER");
}

//If no TDUID was found, send an empty string.
if (tduid == empty) {
    tduid = "";

//Replace value with organization ID provided by Tradedoubler.
organization = "12345";

//Replace value with event ID provided by Tradedoubler.
event = "5";

//Replace value with secret code provided by Tradedoubler.
secretcode = "12345";

//Set value of order number. This value has to be unique for each order.
orderNumber = "abc-12345";

//Set value of order value. Do not include currency symbols or thousand separators.
orderValue = "10.99";

//Set currency.
currency = "EUR";

//Set value of extid. This must be the email address hashed using SHA-256.
extid = "email_address";

//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
exttype = "1";

//Set voucher code.
voucher = "SALEXMAS2014"

//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "12345";

//Send the entire report to Tradedoubler.
//Important! Use https if on secure server.
<iframe src="https://tbs.tradedoubler.com/report?organization=%organization%&event=%event%&orderNumber=%orderNumber%&orderValue=%orderValue%&currency=%currency%&extid=%extid%&exttype=%exttype%&voucher=%voucher%&checksum=%checksum%&tduid=%tduid%&type=iframe" frameborder="0" width="1" height="1"></iframe>

ASP tracking pixel script

<!-- #include file="md5.asp" -->
<%
Dim organization, orderValue, currencyCode, eventId
Dim isSale, isSecure, orderNumber, tduid, reportInfo
Dim domain, checkNumberName, scheme, trackBackUrl
'
' Your organization ID
organization = "xxxx"
'
' Value of the sale.
orderValue = "0.00"
'
' Currency of the sale.
currencyCode = "EUR"
'
'Set value of extid. This must be the email address hashed using SHA-256.
extid = "email_address"
'
'Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
exttype = "1"
'
' Voucher code used by user.
voucher = "VoucherCode"
'
' Event ID
eventId = "xxxx"
'
' Event type:
' True = Sale
' False = Lead
isSale = True
'
' Encrypted connection on this page:
' True = Yes (https)
' False = No (http)
isSecure = True
'
' A unique identifier for the transaction. For a sale, this is typically the order number.
orderNumber = "xxxxxxxx"
'
' If you do not use the built-in session functionality in ASP.NET, modify
' the following expressions to work with your session handling routines.
If Session("TRADEDOUBLER") <> "" Then
	tduid = Session("TRADEDOUBLER")
End If
'
' You may transmit a list of items ordered in the reportInfo parameter.
reportInfo = ""
reportInfo = Server.URLEncode(reportInfo)
'
'***** IMPORTANT: *****
'***** Please consult Tradedoubler before modifying the code below this line. *****
If Request.Cookies("TRADEDOUBLER") <> "" Then
	tduid = Request.Cookies("TRADEDOUBLER")
End If
If (isSale) Then
	domain = "tbs.tradedoubler.com"
	checkNumberName = "orderNumber"
Else
	domain = "tbl.tradedoubler.com"
	checkNumberName = "leadNumber"
	orderValue = "1"
End If
'Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx"
If isSecure Then
	scheme = "https"
Else
	scheme = "http"
End If
trackBackUrl = scheme & "://" & domain & "/report" _
	& "?organization=" & organization _
	& "&event=" & eventId _
	& "&" & checkNumberName & "=" & orderNumber _
	& "&checksum=" & checksum _
	& "&tduid=" & tduid _
	& "&extid=" & extid _
	& "&exttype=" & exttype _
	& "&type=iframe" _
	& "&reportInfo=" & reportInfo
If (isSale) Then
	trackBackUrl = trackBackUrl _
		& "&orderValue=" & orderValue _
		& "&currency=" & currencyCode _
		& "&voucher=" & voucher
End If
Response.Write("<iframe src=\"" & trackBackUrl & "\"  frameborder=\"0\" width=\"1\" height=\"1\"></iframe>");

C# tracking pixel script

<%@Page Language="C#"%>
<%
//
// Your organization ID
string organization = "xxxx";
//
// Value of the sale.
string orderValue = "0.00";
//
// Currency of the sale.
string currency = "EUR";
//
//Set value of extid. This must be the email address hashed using SHA-256.
extid = "email_address";
//
//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
exttype = "1";
//
// Voucher code used by user.
string voucher = "VoucherCode";
//
// Event ID
string eventId = "xxxx";
//
// Event type:
// true = Sale
// false = Lead
bool isSale = true;
//
// Encrypted connection on this page:
// true = Yes (https)
// false = No (http)
bool isSecure = true;
//
// A unique identifier for the transaction. For a sale, this is typically the order number.
string orderNumber = "xxxxxxxx";
//
// If you do not use the built-in session functionality in ASP.NET, modify
// the following expressions to work with your session handling routines.
string tduid = "";
if (Session["TRADEDOUBLER"] != null)
	tduid = (string) Session["TRADEDOUBLER"];
//
// You may transmit a list of items ordered in the reportInfo parameter.
string reportInfo = "";
reportInfo = Server.UrlEncode(reportInfo);
//
//***** IMPORTANT: *****
//***** Please consult Tradedoubler before modifying the code below this line. *****
if (Request.Cookies["TRADEDOUBLER"] != null)
	tduid = Request.Cookies["TRADEDOUBLER"].Value;
string domain, checkNumberName;
string scheme, trackBackUrl;
if (isSale)
{
	domain = "tbs.tradedoubler.com";
	checkNumberName = "orderNumber";
}
else
{
	domain = "tbl.tradedoubler.com";
	checkNumberName = "leadNumber";
	orderValue = "1";
}
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx";
if (isSecure)
	scheme = "https";
else
	scheme = "http";
trackBackUrl = scheme + "://" + domain + "/report"
	+ "?organization=" + organization
	+ "&event=" + eventId
	+ "&" + checkNumberName + "=" + orderNumber
	+ "&checksum=" + checksum
	+ "&tduid=" + tduid
	+ "&extid=" + extid
	+ "&exttype=" + exttype
	+ "&type=iframe"
	+ "&reportInfo=" + reportInfo;
if (isSale)
{
	trackBackUrl
	+= "&orderValue= + orderValue
	+ "&currency=" + currency
	+ "&voucher=" + voucher;
}
Response.Write("<iframe src=\"" + trackBackUrl + "\"  frameborder=\"0\" width=\"1\" height=\"1\"></iframe>");
%>

JavaScript tracking pixel script

<script type="text/javascript">
// Your organization ID
var organization=xxxxx;
//
// Value of the sale.
var orderValue = "0.00";
//
// Currency of the sale.
var currency = "EUR";
//
//Set value of extid. This must be the email address hashed using SHA-256.
var extid = "email_address";
//
//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
var exttype = "1";
//
// Voucher code used by user.
var voucher = "VoucherCode";
//
// Event ID
var event=xxxxx;
//
// Event type:
// true = Sale
// false = Lead
var isSale = true;
//
// Encrypted connection on this page:
// true = Yes (https)
// false = No (http)
var isSecure = true;
//
// A unique identifier for the transaction. For a sale, this is typically the order number.
var orderNumber = "xxxxx";
//
// You may transmit a list of items ordered in the reportInfo parameter.
var reportInfo = "";
reportInfo = escape(reportInfo);
//
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
var tduid = getCookie("TRADEDOUBLER");
/***** IMPORTANT: *****/
/***** Please consult Tradedoubler before modifying the code below this line. *****/
if (isSale)
{
	var domain = "tbs.tradedoubler.com";
	var checkNumberName = "orderNumber";
}
else
{
	var domain = "tbl.tradedoubler.com";
	var checkNumberName = "leadNumber";
	var orderValue = "1";
}
//
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
var checksum = "xxxxx";
//
if (isSecure)
	var scheme = "https";
else
	var scheme = "http";
//
var trackBackUrl = scheme + "://" + domain + "/report" + "?organization=" + organization + "&event=" + event + "&" + checkNumberName + "=" + orderNumber + "&checksum=" + checksum + "&tduid=" + tduid + "&extid=" + extid + "&exttype=" + exttype + "&type=iframe&reportInfo=" + reportInfo;
if (isSale)
{
	trackBackUrl = trackBackUrl + "&orderValue=" + orderValue + "&currency=" + currency + "&voucher=" + voucher;
}
//
function prepareFrame(tburl){
	ifrm = document.createElement("IFRAME");
	ifrm.setAttribute("src", tburl);
	ifrm.style.width = 1+"px";
	ifrm.style.height = 1+"px";
	ifrm.style.border = "none";
	document.body.appendChild(ifrm);
}
prepareFrame(trackBackUrl);
</script>

JSP tracking pixel script

<%@ page import="com.tradedoubler.general.md5.*" %>
<%
// The above import must be in your classpath!
// Your organization ID
String organization = "xxxx";
//
// Value of the sale.
String orderValue = "0.00";
//
// Currency of the sale.
String currency = "EUR";
//
//Set value of extid. This must be the email address hashed using SHA-256.
String extid = "email_address";
//
//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
String exttype = "1";
//
// Voucher code used by user.
String voucher = "VoucherCode";
//
// Event ID
String event = "xxxx";
//
// Event type:
// true = Sale
// false = Lead
boolean isSale = true;
//
// Encrypted connection on this page:
// true = Yes (https)
// false = No (http)
boolean isSecure = true;
//
// A unique identifier for the transaction. For a sale, this is typically the order number.
String orderNumber = "xxxxxxxx";
//
// If you do not use the built-in session functionality in JSP, modify
// the following expressions to work with your session handling routines.
String tduid = "";
if (session.getAttribute("TRADEDOUBLER") != null)
	tduid = (String) session.getAttribute("TRADEDOUBLER");
//
// You may transmit a list of items ordered in the reportInfo parameter.
String reportInfo = "";
reportInfo = java.net.URLEncoder.encode(reportInfo, "UTF-8");
//
/***** IMPORTANT: *****/
/***** Please consult Tradedoubler before modifying the code below this line. *****/
Cookie[] cookies = request.getCookies();
if (cookies != null) {
	for (int i = 0; i < cookies.length; i++) {
		if (cookies[i].getName().equals("TRADEDOUBLER")) {
			if (cookies[i].getValue() != null) {
				tduid = cookies[i].getValue();
			}
		}
	}
}
String domain, checkNumberName;
String scheme, trackBackUrl;
if (isSale) {
	domain = "tbs.tradedoubler.com";
	checkNumberName = "orderNumber";
} else {
	domain = "tbl.tradedoubler.com";
	checkNumberName = "leadNumber";
	orderValue = "1";
}
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx";
if (isSecure)
	scheme = "https";
else
	scheme = "http";
trackBackUrl = scheme + "://" + domain + "/report"
	+ "?organization=" + organization
	+ "&event=" + event
	+ "&" + checkNumberName + "=" + orderNumber
	+ "&checksum=" + checksum
	+ "&tduid=" + tduid
	+ "&extid=" + extid
	+ "&exttype=" + exttype
	+ "&type=iframe"
	+ "&reportInfo=" + reportInfo;
if (isSale) {
	trackBackUrl
		+= "&orderValue=" + orderValue
		+ "&currency=" + currency
		+ "&voucher=" + voucher;
}
%>
<iframe src="<%=trackBackUrl%>" frameborder="0" width="1" height="1"></iframe>;

Perl tracking pixel script

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
use URI::Escape;
use Digest::MD5 qw(md5_hex);
my $query = new CGI;
# Your organization ID
my $organization = "xxxx";
#
# Value of the sale.
my $orderValue = "0.00";
#
# Currency of the sale.
my $currency = "EUR";
#
# Set value of extid. This must be the email address hashed using SHA-256.
my $extid = "email_address";
#
# Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
my $exttype = "1";
#
# Voucher code used by user.
my $voucher = "VoucherCode";
#
# Event ID
my $event = "xxxx";
#
# Event type:
# 1 = Sale
# 0 = Lead
my $isSale = 1;
#
# Encrypted connection on this page:
# 1 = Yes (https)
# 0 = No (http)
my $isSecure = 1;
#
# A unique identifier for the transaction. For a sale, this is typically the order number.
my $orderNumber = "xxxxxxxx";
#
# If you passed the tduid through your system, we'll take the tduid from
# the url
my $tduid;
if($query->url_param('tduid') ne "")
{
	$tduid = $query->url_param('tduid');
}
#
# You may transmit a list of items ordered in the reportInfo parameter.
my $reportInfo = "";
#
#***** IMPORTANT: *****#
#***** Please consult Tradedoubler before modifying the code below this line. *****#
$reportInfo = uri_escape($reportInfo);
my %cookies = fetch CGI::Cookie;
if( $cookies{'TRADEDOUBLER'}->value ne "")
{
	$tduid = $cookies{'TRADEDOUBLER'}->value;
}
my $domain;
my $checkNumberName;
if ($isSale)
{
	$domain = "tbs.tradedoubler.com";
	$checkNumberName = "orderNumber";
}
else
{
	$domain = "tbl.tradedoubler.com";
	$checkNumberName = "leadNumber";
	$orderValue = "1";
}
# Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx";
my $scheme;
if ($isSecure)
{
	$scheme = "https";
}
else
{
	$scheme = "http";
}
my $trackBackUrl = $scheme . "://" . $domain . "/report"
	. "?organization=" . $organization
	. "&event=" . $event
	. "&" . $checkNumberName . "=" . $orderNumber
	. "&checksum=" . $checksum
	. "&tduid=" . $tduid
	. "&extid=" . $extid
	. "&exttype=" . $exttype
	. "&type=iframe"
	. "&reportInfo=" . $reportInfo;
if ($isSale)
{
	$trackBackUrl
	.= "&orderValue=" . $orderValue
	. "&currency=" . $currency
	. "&voucher=" . $voucher;
}
my $trackbackImage = "<iframe src=\"" . $trackBackUrl . "\" frameborder=\"0\"  width=\"1\" height=\"1\"></iframe>";
#
# DEBUG OUTPUT
print $query->header;
print $query->start_html();
print "<!--\n" . $trackbackImage . "\n-->";
print $query->end_html;

PHP tracking pixel script

<?php
// Open session for cookie handling
session_start();
//
// Your organization ID
$organization = xxxx;
//
// Value of the sale.
$orderValue = "0.00";
//
// Currency of the sale.
$currency = "EUR";
//
//Set value of extid. This must be the email address hashed using SHA-256.
$extid = "email_address";
//
//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
$exttype = "1";
//
// Voucher code used by user.
$voucher = "VoucherCode";
//
// Event ID
$event = xxxx;
//
// Event type:
// true = Sale
// false = Lead
$isSale = true;
//
// Encrypted connection on this page:
// true = Yes (https)
// false = No (http)
$isSecure = true;
//
// A unique identifier for the transaction. For a sale, this is typically the order number.
$orderNumber = "xxxxxxxx";
//
// If you do not use the built-in session functionality in PHP, modify
// the following expressions to work with your session handling routines.
$tduid = "";
if (!empty($_SESSION["TRADEDOUBLER"]))
	$tduid = $_SESSION["TRADEDOUBLER"];
//
// You may transmit a list of items ordered in the reportInfo parameter.
$reportInfo = "";
$reportInfo = urlencode($reportInfo);
//
/***** IMPORTANT: *****/
/***** Please consult Tradedoubler before modifying the code below this line. *****/
if (!empty($_COOKIE["TRADEDOUBLER"]))
	$tduid = $_COOKIE["TRADEDOUBLER"];
if ($isSale)
{
	$domain = "tbs.tradedoubler.com";
	$checkNumberName = "orderNumber";
}
else
{
	$domain = "tbl.tradedoubler.com";
	$checkNumberName = "leadNumber";
	$orderValue = "1";
}
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx";
if ($isSecure)
	$scheme = "https";
else
	$scheme = "http";
$trackBackUrl = $scheme . "://" . $domain . "/report"
	. "?organization=" . $organization
	. "&event=" . $event
	. "&" . $checkNumberName . "=" . $orderNumber
	. "&checksum=" . $checksum
	. "&tduid=" . $tduid
	. "&extid=" . $extid
	. "&exttype=" . $exttype
	. "&type=iframe"
	. "&reportInfo=" . $reportInfo;
if ($isSale)
{
	$trackBackUrl
	.= "&orderValue=" . $orderValue
	. "&currency=" . $currency
	. "&voucher=" . $voucher;

}
echo "<iframe src=\"" . $trackBackUrl . "\" frameborder=\"0\"  width=\"1\" height=\"1\"></iframe>";
?>

VB.NET tracking pixel script

<%@Page Language="VB"%><%
<%
' Your organization ID
Dim organization As String = "xxxx"
'
' Value of the sale.
Dim orderValue As String = "0.00"
'
' Currency of the sale.
Dim currency As String = "EUR"
'
' Set value of extid. This must be the email address hashed using SHA-256.
Dim extid As String = "email_address"
'
' Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
Dim exttype As String = "1"
'
' Voucher code used by the user.
Dim voucher As String = "VoucherCode"
'
' Event ID
Dim eventId As String = "xxxx"
'
' Event type:
' True = Sale
' False = Lead
Dim isSale As Boolean = True
'
' Encrypted connection on this page:
' True = Yes (https)
' False = No (http)
Dim isSecure As Boolean = True
'
' A unique identifier for the transaction. For a sale, this is typically the order number.
Dim orderNumber As String = "xxxxxxxx"
'
' If you do not use the built-in session functionality in ASP.NET, modify
' the following expressions to work with your session handling routines.
Dim tduid As String
If Not Session.Item("TRADEDOUBLER") Is Nothing Then
	tduid = Session.Item("TRADEDOUBLER")
End If
'
' You may transmit a list of items ordered in the reportInfo parameter.
Dim reportInfo As String
reportInfo = Server.UrlEncode(reportInfo)
'
'***** IMPORTANT: *****
'***** Please consult Tradedoubler before modifying the code below this line. *****
If Not Request.Cookies("TRADEDOUBLER") Is Nothing Then
	tduid = Request.Cookies("TRADEDOUBLER").Value
End If
Dim domain, checkNumberName As String
Dim scheme, trackBackUrl As String
If isSale
	domain = "tbs.tradedoubler.com"
	checkNumberName = "orderNumber"
Else
	domain = "tbl.tradedoubler.com"
	checkNumberName = "leadNumber"
	orderValue = "1"
End If
' Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
checksum = "xxxxx"
If isSecure
	scheme = "https"
Else
	scheme = "http"
End If
trackBackUrl = scheme & "://" & domain & "/report" _
	& "?organization=" & organization _
	& "&event=" & eventId _
	& "&" & checkNumberName & "=" & orderNumber _
	& "&checksum=" & checksum _
	& "&tduid=" & tduid _
	& "&extid=" & extid _
	& "&exttype=" & exttype _
	& "&type=iframe"
	& "&reportInfo=" & reportInfo
If isSale
	trackBackUrl _
		&= "&orderValue=" & orderValue _
		& "&currency=" & currency _
		& "&voucher=" & voucher
End If
Response.Write("<iframe src=""" & trackBackUrl & """ frameborder=""0"" width=""1"" height=""1""></iframe>")
%>

Example PLT scripts

This section includes tracking pixel scripts in various programming languages as well as a pseudo code version to explain what the code is doing.


PLT pixel script pseudo code

//Get the TDUID from the session. The TDUID is provided by Tradedoubler on the redirect URL and is unique per user.
tduid = session.get("TRADEDOUBLER");

//Get the TDUID cookie and override the value from the session if the cookie is found.
if (cookie.get("TRADEDOUBLER") != empty) {
    tduid = cookie.get("TRADEDOUBLER");
}

//If no TDUID was found, send an empty string.
if (tduid == empty) {
    tduid = "";

//Replace value with organization ID provided by Tradedoubler.
o = "12345";

//Replace value with event ID provided by Tradedoubler.
event = "51";

//Set value of order number. This value has to be unique for each order.
ordnum = "abc-12345";

//Set currency.
curr = "EUR";

//Set value of extid. This must be the email address hashed using SHA-256.
extid = "email_address";

//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
exttype = "1";

//Set voucher code. This can be replaced by a variable of the confirmation page.
voucher = "SALEXMAS2014";

//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
chksum = "12345";

//Basket. This information is used to send specific product details regarding the order to Tradedoubler.
//Iterate pr, i, n, gr, v, q for each product in the basket.
//pr() is product row and distinguishes each product row.
//i() is product ID.
//n() is product name.
//gr() is product group ID, supplied by Tradedoubler.
//v() is product value. Use a decimal point (.) as decimal sign.
//q() is product quantity for that item within the basket.

basket = "(pr(i(%productId%)n(%productName%)gr(%ProductGroupId%)v(%productValue%)q(%productQuantity%)))";

//Important! The i and n parameter values should be encoded in the corresponding format that the enc parameter specifies.
//Set encoding for product ID and product name.
enc = "3";

//Send the entire report to Tradedoubler.
//Important! Use https if on secure server.
<iframe src="https://tbs.tradedoubler.com/report?o(%organization%)event(%event%)ordnum(%ordnum%)curr(%curr%)chksum(%chksum%)tduid(%tduid%)extid(%extid%)exttype(%exttype%)type(iframe)enc(%enc%)basket(%basket%)" frameborder="0" width="1" height="1"></iframe>;

ASP PLT pixel script

<!-- #include file="md5.asp" -->
<%
Dim organization, orderValue, currencyCode, eventId, voucher
Dim isSale, isSecure, orderNumber, tduid, reportInfo
Dim domain, checkNumberName, scheme, trackBackUrl
Dim encoding, basket
Dim productGroup = 0
Dim productId = 1
Dim productName = 2
Dim productQuantity = 3
Dim productValue = 4
'Your organization ID.
organization = "xxxxx"
'
'Currency of the sale.
currencyCode = "EUR"
'
'Set value of extid. This must be the email address hashed using SHA-256.
extid = "email_address"
'
'Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
exttype = "1"
'
'Voucher code (if used).
voucher = "xxxxx"
'
'Encoding type
' 0, if encoding is Cp1252
' 1, if encoding is ISO_8859_1
' 2, if encoding is ISO_8859_15
' 3, if encoding is UTF_8
' 4, if encoding is UTF_16
' 5, if encoding is ISO_8859_4
' 6, if encoding is ISO_8859_2
encoding = "3"
'
' Event type:
' True = Sale
' False = Lead
isSale = True
'
' Encrypted connection on this page:
' True = Yes (https)
' False = No (http)
isSecure = True
'
' A unique identifier for the transaction. For a sale, this is typically the order number.
orderNumber = "xxxxxxxx"
'
' If you do not use the built-in session functionality in ASP.NET, modify
' the following expressions to work with your session handling routines.
If Session("TRADEDOUBLER") <> "" Then
	tduid = Session("TRADEDOUBLER")
End If
'
'Basket info
'Fill the array with your data. This is an example of the multidimensional array used.
'Long fields will automatically be shortened if needed.
'Dim basketArray(3,5)
'basketArray(0,productGroup) = "23"
'basketArray(0,productId) = "ID001"
'basketArray(0,productName) = "Apple iPod 16GB - white"
'basketArray(0,productValue) = "99.12"
'basketArray(0,productQuantity) = "2"
'
'basketArray(1,productGroup) = "21"
'basketArray(1,productId) = "ID002"
'basketArray(1,productName) = "ASUS K11N Super Mainboard"
'basketArray(1,productValue) = "322.95"
'basketArray(1,productQuantity) = "1"
'
basket = "basket("
For pr=0 to Ubound(basketArray,1)
	basket = basket & "pr("
	basket = basket & "gr(" & basketArray(pr,productGroup) & ")"
	basket = basket & "i(" & Server.URLEncode(basketArray(pr,productId)) & ")"
	basket = basket & "n(" & Server.URLEncode(basketArray(pr,productName)) & ")"
	basket = basket & "v(" & basketArray(pr,productValue) & ")"
	basket = basket & "q(" & basketArray(pr,productQuantity) & ")"
	basket = basket & ")"
Next
basket = basket & ")"
'
'***** IMPORTANT: *****
'***** Please consult Tradedoubler before modifying the code below this line. *****
orderValue = "1"
eventId = "51"
If Request.Cookies("TRADEDOUBLER") <> "" Then
	tduid = Request.Cookies("TRADEDOUBLER")
End If
If (isSale) Then
	domain = "tbs.tradedoubler.com"
	checkNumberName = "ordnum"
Else
	domain = "tbl.tradedoubler.com"
	checkNumberName = "leadNumber"
	orderValue = "1"
End If
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
chksum = "xxxxx"
If isSecure Then
	scheme = "https"
Else
	scheme = "http"
End If
trackBackUrl = scheme & "://" & domain & "/report" _
	& "?o(" & organization & ")" _
	& "event(" & eventId & ")" _
	& checkNumberName & "(" & orderNumber & ")" _
	& "chksum(" & chksum & ")" _
	& "enc(" & encoding & ")" _
	& "tduid(" & tduid & ")" _
	& "extid(" & extid & ")" _
	& "exttype(" & exttype & ")" _
	& "type(iframe)" _
	& "voucher(" & voucher & ")" _
	& basket
If (isSale) Then
	trackBackUrl = trackBackUrl _
	& "curr(" & currencyCode & ")"
End If
Response.Write("<iframe src=\"" & trackBackUrl & "\"  frameborder=\"0\" width=\"1\" height=\"1\"></iframe>");

JavaScript PLT pixel script

<script language="Javascript">
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
var tduid = getCookie("TRADEDOUBLER");
// Your organization ID
var organization = xxxxx;
// A unique identifier for the transaction. For a sale, this is typically the order number.
var ordernumber = "xxxxx";
// Currency of the sale.
var currency = "EUR";
// Set value of extid. This must be the email address hashed using SHA-256.
var extid = "email_address";
// Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
var exttype = "1";
// Voucher code (if used).
var voucher = "xxxxx";
//Write here the encoding type
// 0, if encoding is Cp1252
// 1, if encoding is ISO_8859_1
// 2, if encoding is ISO_8859_15
// 3, if encoding is UTF_8
// 4, if encoding is UTF_16
// 5, if encoding is ISO_8859_4
// 6, if encoding is ISO_8859_2
var encoding = "3";
//Basket info
//Fill the array with your data. This is an example of the multidimensional array used.
//Long fields will automatically be shortened if needed.
// basket[0]["productGroup"]="23";
// basket[0]["productId"]="ID001";
// basket[0]["productName"]="Apple iPod 16GB - white";
// basket[0]["productValue"]="99.12";
// basket[0]["productQuantity"]="1";
//
// basket[1]["productGroup"]="21";
// basket[1]["productId"]="ID002";
// basket[1]["productName"]="ASUS K11N Super Mainboard";
// basket[1]["productValue"]="322.95";
// basket[1]["productQuantity"]="1";
//
var basketstring="basket(";
var arrayLength = basket.length;
for (pr=0; pr < arraylength; pr++){
	if (basket[pr]["productName"].length>20) {
		basket[pr]["productName"] = basket[pr]["productName"].substr(0,20);
	}
	basket[pr]["productName"] = escape(basket[pr]["productName"]);
	basketstring = basketstring + "pr(";
	basketstring = basketstring + "i(" + basket[pr]["productId"] + ")";
	basketstring = basketstring + "n(" + basket[pr]["productName"] + ")";
	basketstring = basketstring + "gr(" + basket[pr]["productGroup"] + ")";
	basketstring = basketstring + "v(" + basket[pr]["productValue"] + ")";
	basketstring = basketstring + "q(" + basket[pr]["productQuantity"] + ")";
	basketstring = basketstring + ")";
}

basketstring  += ")";  // close the basket
// Build the final string:
var trackBackUrl = "http://tbs.tradedoubler.com/report?o(" + organization + ")event(51)ordnum(" + ordernumber + ")tduid(" + tduid + ")extid(" + extid + ")exttype(" + exttype + ")type(iframe)curr(" + currency + ")voucher(" + voucher + ")enc(" + encoding + ")";
trackBackUrl = trackBackUrl + basketstring;
//Display trackback
function prepareFrame(tburl){
	ifrm = document.createElement("IFRAME");
	ifrm.setAttribute("src", tburl);
	ifrm.style.width = 1+"px";
	ifrm.style.height = 1+"px";
	ifrm.style.border = "none";
	document.body.appendChild(ifrm);
}
prepareFrame(trackBackUrl);
</script>

PHP PLT pixel script

<?php
// Open session for cookie handling
session_start();
//
//Your organization ID.
$TD_Trackback['organisation'] = xxxxx;
//
//Currency of the sale.
$TD_Trackback['currency'] = 'EUR';
//
//Voucher code (if used).
$TD_Trackback['voucher'] = 'xxxxx';
//
//A unique identifier for the transaction. For a sale, this is typically the order number.
$TD_Trackback['orderNumber'] = 'xxxxx';
//
//Set value of extid. This must be the email address hashed using SHA-256.
$TD_Trackback['extid'] = 'email_address';
//
//Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
$TD_Trackback['exttype'] = '1';
//
//Write here the encoding type
// 0, if encoding is Cp1252
// 1, if encoding is ISO_8859_1
// 2, if encoding is ISO_8859_15
// 3, if encoding is UTF_8
// 4, if encoding is UTF_16
// 5, if encoding is ISO_8859_4
// 6, if encoding is ISO_8859_2
$TD_Trackback['encoding'] = '3';
//
// If you do not use the built-in session functionality in PHP, modify
// the following expressions to work with your session handling routines.
$TD_Trackback['tduid'] = '';
if (!empty($_SESSION['TRADEDOUBLER'])) { $TD_Trackback['tduid'] = $_SESSION['TRADEDOUBLER']; }
//
// Encrypted connection on this page:
// true = Yes (https)
// false = No (http)
$TD_Trackback['isSecure'] = true;
//
//Basket info
//Fill the array with your data. This is an example of the multidimensional array used.
//Long fields will automatically be shortened if needed.
//$TD_Products[0]['productGroup'] = '23';
//$TD_Products[0]['productID'] = 'ID001';
//$TD_Products[0]['productName'] = 'Apple iPod 16GB - white';
//$TD_Products[0]['productValue'] = '99.12';
//$TD_Products[0]['productQuantity'] = '1';
//
//$TD_Products[1]['productGroup'] = '21';
//$TD_Products[1]['productID'] = 'ID002';
//$TD_Products[1]['productName'] = 'ASUS K11N Super Mainboard';
//$TD_Products[1]['productValue'] = '322.95';
//$TD_Products[1]['productQuantity'] = '1';
//
/***** IMPORTANT: *****/
/***** Please consult Tradedoubler before modifying the code below this line. *****/
$TD_Trackback['orderValue'] = '1'; // Static for PLT - Do not modify
$TD_Trackback['event'] = '51'; // Static for PLT - Do not modify
if (!empty($_COOKIE['TRADEDOUBLER'])) { $TD_Trackback['tduid'] = $_COOKIE['TRADEDOUBLER']; }
if ($TD_Trackback['isSecure']) { $TD_Trackback['scheme'] = "https"; }
else { $TD_Trackback['scheme'] = "http"; }
$TD_Trackback['domain'] = "tbs.tradedoubler.com";
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
chksum = "xxxxx";
//
// Put the basket together
$TD_Trackback['basket'] = 'basket(';
foreach ($TD_Products as $Product) {
	$TD_Trackback['basket'] .= 'pr(';
	$TD_Trackback['basket'] .= 'gr('.rawurlencode($Product['productGroup']).')';
	$TD_Trackback['basket'] .= 'i('.substr(preg_replace("/[^a-zA-Z0-9._-]/", "", $Product['productID']),0,20).')';
	$TD_Trackback['basket'] .= 'n('.rawurlencode(substr($Product['productName'],0,20)).')';
	$TD_Trackback['basket'] .= 'v('.rawurlencode($Product['productValue']).')';
	$TD_Trackback['basket'] .= 'q('.rawurlencode($Product['productQuantity']).')';
	$TD_Trackback['basket'] .= ')';
}
$TD_Trackback['basket'] .= ")";
//
// Put the trackback-URL together
$TD_Trackback['url'] = $TD_Trackback['scheme'] . '://tbs.tradedoubler.com/report?';
$TD_Trackback['url'] .= 'o(' . $TD_Trackback['organisation'] . ')';
$TD_Trackback['url'] .= 'event(' . $TD_Trackback['event'] . ')';
$TD_Trackback['url'] .= 'ordnum(' . $TD_Trackback['orderNumber'] . ')';
$TD_Trackback['url'] .= 'curr(' . $TD_Trackback['currency'] . ')';
$TD_Trackback['url'] .= 'voucher(' . $TD_Trackback['voucher'] . ')';
$TD_Trackback['url'] .= 'chksum(' . $TD_Trackback['chksum'] . ')';
$TD_Trackback['url'] .= 'tduid(' . $TD_Trackback['tduid']. ')';
$TD_Trackback['url'] .= 'extid(' . $TD_Trackback['extid']. ')';
$TD_Trackback['url'] .= 'exttype(' . $TD_Trackback['exttype']. ')';
$TD_Trackback['url'] .= 'type(iframe)';
$TD_Trackback['url'] .= 'enc(' . $TD_Trackback['encoding'] . ')';
$TD_Trackback['url'] .= $TD_Trackback['basket'];
// Display the trackback
echo '<iframe src="'.$TD_Trackback['url'].'" frameborder="0" width="1" height="1"></iframe>';
?>

VB.NET PLT pixel script

<%@Page Language="VB"%>
<%
Dim productGroup = 0
Dim productId = 1
Dim productName = 2
Dim productQuantity = 3
Dim productValue = 4
'
Your organization ID.
Dim organization As String = "xxxxx"
'
' Currency of the sale.
Dim currency As String = "EUR"
'
' Voucher code (if used).
Dim voucher As String = "xxxxx"
'
' Set value of extid. This must be the email address hashed using SHA-256.
Dim extid As String = "email_address"
'
' Set the value of the external ID type. If an email address is used for extid, exttype=1. If an internal user ID is used, exttype=0.
Dim exttype As String = "1"
'
' Event type:
' True = Sale
' False = Lead
Dim isSale As Boolean = True
'
' Encrypted connection on this page:
' True = Yes (https)
' False = No (http)
Dim isSecure As Boolean = True
'
'Write here the encoding type
' 0, if encoding is Cp1252
' 1, if encoding is ISO_8859_1
' 2, if encoding is ISO_8859_15
' 3, if encoding is UTF_8
' 4, if encoding is UTF_16
' 5, if encoding is ISO_8859_4
' 6, if encoding is ISO_8859_2
Dim encoding = "3"
'
'Basket info
'Fill the array with your data. This is an example of the multidimensional array used.
'Long fields will automatically be shortened if needed.
'Dim basketArray(3,5)
'basketArray(0,productGroup) = "23"
'basketArray(0,productId) = "ID001"
'basketArray(0,productName) = "Apple iPod 16GB - white"
'basketArray(0,productValue) = "99.12"
'basketArray(0,productQuantity) = "2"
'
'basketArray(1,productGroup) = "21"
'basketArray(1,productId) = "ID002"
'basketArray(1,productName) = "ASUS K11N Super Mainboard"
'basketArray(1,productValue) = "322.95"
'basketArray(1,productQuantity) = "1"
'
Dim basket = "basket("
For pr=0 to Ubound(basketArray,1)
	basket = basket & "pr("
	basket = basket & "gr(" & basketArray(pr,productGroup) & ")"
	basket = basket & "i(" & Server.URLEncode(basketArray(pr,productId)) & ")"
	basket = basket & "n(" & Server.URLEncode(basketArray(pr,productName)) & ")"
	basket = basket & "v(" & basketArray(pr,productValue) & ")"
	basket = basket & "q(" & basketArray(pr,productQuantity) & ")"
	basket = basket & ")"
Next
basket = basket & ")"
'
' If you do not use the built-in session functionality in ASP.NET, modify
' the following expressions to work with your session handling routines.
Dim tduid As String
If Not Session.Item("TRADEDOUBLER") Is Nothing Then
	tduid = Session.Item("TRADEDOUBLER")
End If
'
'***** IMPORTANT: *****
'***** Please consult Tradedoubler before modifying the code below this line. *****
If Not Request.Cookies("TRADEDOUBLER") Is Nothing Then
	tduid = Request.Cookies("TRADEDOUBLER").Value
End If
Dim domain, checkNumberName As String
Dim scheme, trackBackUrl As String
Dim orderValue As String = "1" // Static for PLT - Do not modify
Dim eventId As String = "51" // Static for PLT - Do not modify
If isSale
	domain = "tbs.tradedoubler.com"
	checkNumberName = "ordnum"
Else
	domain = "tbl.tradedoubler.com"
	checkNumberName = "leadNumber"
	orderValue = "1"
End If
//Create the checksum. Your Tradedoubler contact will explain how it should be implemented.
chksum = "xxxxx"

If isSecure
	scheme = "https"
Else
	scheme = "http"
End If
trackBackUrl = scheme & "://" & domain & "/report" _
	& "?o(" & organization & ")" _
	& "event(" & eventId & ")" _
	& checkNumberName & "(" & orderNumber & ")" _
	& "chksum(" & chksum & ")" _
	& "enc(" & encoding & ")" _
	& "tduid(" & tduid & ")" _
	& "extid(" & extid & ")" _
	& "exttype(" & exttype & ")" _
	& "type(iframe)" _
	& basket
If (isSale) Then
	trackBackUrl = trackBackUrl _
		& "curr(" & currencyCode & ")"
		& "voucher(" & voucher & ")"
End If
Response.Write("<iframe src=""" & trackBackUrl & """ frameborder=""0"" width=""1"" height=""1""></iframe>")
%>