---
title: 'Criteo OneTag advanced settings'
description: 'To enable a number of advanced settings, there are several modifications you can make to your Criteo OneTag implementation. These address cross-device…'
language: en
guide: M2TiX6m90K
updated: 2025-11-12T13:21:16Z
canonical: https://help.criteo.com/kb/guide/en/criteo-onetag-advanced-settings-M2TiX6m90K/Steps/886908
alternates:
  de: https://help.criteo.com/kb/guide/de/erweiterte-einstellungen-von-criteo-onetag-M2TiX6m90K.md
  es: https://help.criteo.com/kb/guide/es/configuracion-avanzada-de-criteo-onetag-M2TiX6m90K.md
  fr: https://help.criteo.com/kb/guide/fr/parametres-avances-de-criteo-onetag-M2TiX6m90K.md
  it: https://help.criteo.com/kb/guide/it/impostazioni-avanzate-di-criteo-onetag-M2TiX6m90K.md
  ja: https://help.criteo.com/kb/guide/ja/criteo-tag-M2TiX6m90K.md
  ko: https://help.criteo.com/kb/guide/ko/criteo-onetag-M2TiX6m90K.md
  pt: https://help.criteo.com/kb/guide/pt/configuracoes-avancadas-da-criteo-onetag-M2TiX6m90K.md
  zh: https://help.criteo.com/kb/guide/zh/criteo-onetag-M2TiX6m90K.md
---

> Index of this knowledge base: https://help.criteo.com/llms.txt
>
> Interactive version: https://help.criteo.com/kb/guide/en/criteo-onetag-advanced-settings-M2TiX6m90K/Steps/886908

# Criteo OneTag advanced settings

<a id="step-886908"></a>

## Criteo OneTag advanced settings

To enable a number of advanced settings, there are several modifications you can make to your Criteo OneTag implementation.  
  
These address cross-device targeting, advertisers with multiple currencies/countries, and other topics. Read the table of contents below for instructions on how to make your setup work best for you.

- If "Pass Hashed Emails Through the Cross-Device Event": [Pass hashed emails through Cross-Device Event](#step-887075)
- If "Pass phone numbers with OneTag": [Pass phone numbers with OneTag](#step-4106561)
- If "Event setup for different site types": [Event setup for different site types](#step-887074)
- If "Event setup for multiple countries": [Event setup for multiple countries](#step-887076)
- If "Event setup for multiple currencies": [Event setup for multiple currencies](#step-887079)
- If "Event setup for multiple websites that use the same basket/cart": [Event setup for multiple websites that use the same basket/cart](#step-887071)
- If "Event setup for multiple payment types": [Event setup for multiple payment types](#step-887073)
- If "Event setup for travel advertisers": [Event setup for travel advertisers](#step-887078)
- If "Less/more than 3 product IDs in the Criteo OneTag on search listing pages": [Less/more than 3 product IDs in the Criteo OneTag on search listing pages](#step-887077)
- If "Setup the netID integration": [Setup the netID integration](#step-887072)

<a id="step-887075"></a>

## Pass hashed emails through Cross-Device Event

Implementing the cross-device parameter within Criteo OneTag is essential for:

-   Reaching an addressable audience, particularly on browsers that are more privacy-focused and therefore restrictive on cookies in their default settings, such as Firefox, Safari, and Edge.
    
-   Enabling cross-device capabilities: if a potential customer is browsing products on your website from their mobile device, this parameter makes it possible to later show this customer relevant ads on their desktop device.
    
-   Improving your match rates when you upload contact lists to Commerce Growth or send via API.
    

**How it works**

The cross-device parameter is a small snippet of code that allows you to pass the hashed email addresses of visitors to your website. All email addresses will be hashed, using a SHA-256 algorithm, before being stored on Criteo's servers. Criteo will then use the hash value to match users across each of their devices.  
  
To ensure we protect your customers’ privacy, Criteo will only store the hashed email addresses of your customers on our servers.  
 

**Do I need to update my website's privacy policy?**

You need to ensure your Website Privacy Policy clearly informs your website visitors that email addresses may be collected and shared with third-parties that you collaborate with to optimize campaign performance and that this information is hashed using the latest and most secure SHA256 hashing technology.

Additionally, you should inform your visitors that you respect their privacy, and should they prefer not to share such information, they can do so by selecting their preferred options in your website user cookie compliance banner (CMP).

Please refer to [Criteo's Privacy Policy](https://help.criteo.com/kb/guide/en/the-criteo-privacy-promise-pDIW4yiawH/Steps/775742) for more information, and you may also include the provided link within your website's Privacy Policy section. 

> **Tip:** Should your legal team have any concerns relating to privacy, they may reach out to your Criteo business contact who will connect them with our legal team as needed.

**How to implement the cross-device parameter**

To provide the most flexibility to you, Criteo accepts users' email addresses in these formats:

-   **SHA256 hashed** (in line with industry standards for addressable advertising).
    
-   **MD5** or **SHA256MD5 hashed** (Criteo's legacy methods).
    
-   **Plain text** (we will thereafter use SHA256 encryption on the emails).
    

> **Tip:** **Note**: Criteo is migrating from hashing our emails via MD5/SHA256MD5 to SHA256. To maximize match rates between your data and our identity graph, especially during the migration period, **please share either legacy formats (MD5 or SHA256MD5) alongside the new SHA256 format**.
>
> If you are unable to share both, please **prioritize the SHA256 format**.
>
> If you are sharing plain text, no update is required.

More details on each method of implementing the cross-device parameter:

- If "SHA256 and MD5 (Preferred)": [SHA256 and MD5 (Preferred)](#step-1948825)
- If "SHA256 hashed": [SHA256 hashed](#step-1948824)
- If "Plain text": [Plain text](#step-1948817)
- If "MD5 or SHA256MD5 (Legacy)": [MD5 or SHA256MD5 (Legacy)](#step-1950390)
- If "Hashing functions": [Hashing functions](#step-1948827)
- If "FAQ": [FAQ](#step-1948826)

<a id="step-4106561"></a>

## Pass phone numbers with OneTag

Phone numbers, as well as e-mails, are one of the biggest sources of identity information. In order to maximize our identification capabilities, we decided to accept them as well as an user identifier, as in some regions (APAC or US, for example) they are very representative and easier to share than e-mail addresses or other identifiers.

To improve our compatibility with already established standards in the industry, we have decided to enable phone number collection through Criteo's OneTag. Some of the upsides of sharing phone numbers are:

-   HPN (hashed phone number) is the best representation of a **single user and it persists over time**: In general, people have a single persistent phone number whereas they may have several emails, mobile ids or cookies. 
    
-   HPN improves **our 360 vision of the user**: a user has a single phone number, available for each of his devices. It helps us improve our bidding, our recommendation and thus the performance for our clients. 
    
-   HPN **interoperates** with several identifiers including HEM and some alternative ids. We can:
    
    -   Collect HPN <> alternative ids links and bid directly on the alternative ids. 
        
    -   Collect HEM <> HPN and bid directly with the HEM.
        

**How it works**

We collect the data through a small snippet of code that allows you to pass the phone numbers of visitors to your website. Event though they can be collected in plain or hashed formats, all phone numbers will be hashed, using a SHA-256 algorithm, before being stored on Criteo's servers. Criteo will then use the hash value to match users across each of their devices.

To ensure we protect your customers’ privacy, Criteo will only store the hashed phone numbers of your customers on our servers. In order to be secure enough, we are adding a second hash stored in a secret vault to avoid any reidentification of the users.

**Do I need to update my website's privacy policy?**

You need to ensure your Website Privacy Policy clearly informs your website visitors that phone numbers may be collected and shared with third-parties that you collaborate with to optimize campaign performance and that this information is hashed using the latest and most secure SHA256 hashing technology.

Additionally, you should inform your visitors that you respect their privacy, and should they prefer not to share such information, they can do so by selecting their preferred options in your website user cookie compliance banner (CMP).

Please refer to [Criteo's Privacy Policy](https://help.criteo.com/kb/guide/en/the-criteo-privacy-promise-pDIW4yiawH/Steps/775742) for more information, and you may also include the provided link within your website's Privacy Policy section. 

Should your legal team have any concerns relating to privacy, they may reach out to your Criteo business contact who will connect them with our legal team as needed.

How to implement

To provide the most flexibility to you, Criteo accepts users' phone numbers in these formats:

-   **SHA256 hashed** (in line with industry standards for addressable advertising).
    
-   **Plain text** (we will, immediately before logging the data, use SHA256 encryption on the phone numbers).

- If "SHA256": [SHA256](#step-4106563)
- If "Plain Text": [Plain Text](#step-4106562)

<a id="step-887074"></a>

## Event setup for different site types

```javascript
<script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true"></script>

<script type="text/javascript">

window.criteo_q = window.criteo_q || [];

var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

window.criteo_q.push(

    { event: "setAccount", account: YOUR UNIQUE ACCOUNT ID },

    { event: "setSiteType", type: deviceType },

    { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },

    { event: "viewHome"}

);

</script>
```

The dynamic setSiteType parameter is present in the Criteo OneTag embedded on every page of your site. If your site has different versions to support a range of devices, indicate which version is displayed to the user via "**setSiteType**" parameter:

-   **d** for desktop
    
-   **m** for mobile
    
-   **t** for tablet
    

Examples:  
  
setSiteType parameter on the desktop version of a site:

 `{ event: "setSiteType", type: "d" },`

  
setSiteType parameter on the mobile version of a site: 

 `{ event: "setSiteType", type: "m" },`

  
setSiteType parameter on the tablet version of a site:  
 

`{ event: "setSiteType", type: "t" },`

If you are unable to dynamically send this value, you can use the following script to automatically detect if the user is on desktop, mobile, or tablet:  
 

`var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";`

Then, you need to place the **deviceType** variable in the event. So the "**setSiteType**" parameter would look like this:

 `{ event: "setSiteType", type: deviceType },`

And the Homepage Event would look like the example on the left.

This path ends here.

<a id="step-887076"></a>

## Event setup for multiple countries

```javascript
<script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true"></script>
<script type="text/javascript"> 
    window.criteo_q = window.criteo_q || []; var criteo_ID = #Country Account ID#; 
    var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d"; 
    window.criteo_q.push(          
        { event: "setAccount", account: criteo_ID },          
        { event: "setSiteType", type: deviceType  },          
        { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },                  
        { event: "viewHome"}  ); 
</script>
```

If your website sells products to customers in more than one country, you need to dynamically switch the Criteo **account ID** for each country. 

In the example below, you will see that an additional variable **criteo\_ID** has been added to the Homepage event. The value of this variable needs to be dynamically updated to the specific **#Country Account ID#**, based on the country that the user selects. This logic needs to be added to each instance of the Criteo OneTag on your website.

An example of a country-specific account ID implemented on the Criteo OneTag is on the left.

This path ends here.

<a id="step-887079"></a>

## Event setup for multiple currencies

If users are able to purchase products in different currencies on your website, for example, a travel website where users are booking from all over the world, you may want to define the currency of the product purchased.   
  
Defining the currency will help Criteo display the correct campaign currency in Criteo's reporting to align with your own reporting.  
  
As product prices are only passed in Basket and Transaction events, this feature should only be used for these two events in the Criteo OneTag. If you are only selling products in one currency, this feature should not be used.  
  
The feature only accepts valid ISO currency codes (see [https://www.iso.org/iso-4217-currency-codes.html](https://www.iso.org/iso-4217-currency-codes.html) for more information).

  
The input must thus be a valid 3-letter string corresponding to a currency code (e.g. 'EUR', 'USD', 'JPY'...).

-   ISO currency code
    -   3-letter string
    -   valid currency code (e.g. "EUR", "USD", "BRL"...)
-   uppercase characters
    -   "JPY" is a valid input, while "jpy" is not.

  
**How to use**

Populate the 3-letter string of the currency that the user has selected on your site. The price value needs to be the exact number that appears on the site. If the user selects USD and the price is $100, then the price in the Criteo OneTag needs to be 100, and the currency needs to be USD.  
  
**Syntax**

The parameter is called **currency** and looks like this:

currency: "JPY"  
  
This is an example of the parameter in the **Basket event**:

{ event: "viewBasket", currency : "JPY", item: \[

  { id: "1234", price: 10.2, quantity: 1 },

  { id: "2345", price: 11.2, quantity: 2 }

\]} 

  
And on the **Sales event**:

{ event: "trackTransaction", id: "12345", currency : "JPY", item: \[

  { id: "1234", price: 10.2, quantity: 1 },

  { id: "2345", price: 11.2, quantity: 2 }

\]} 

  

**How to test**

Open your browser debug tool by pressing F12. Search for "criteo" in the Network tab, then navigate to the Basket or Sales Confirmation page (wherever you implemented the currency feature). This is what you will see in the query string parameters:

This path ends here.

<a id="step-887071"></a>

## Event setup for multiple websites that use the same basket/cart

```javascript
<script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true"></script>

 <script type="text/javascript">

 window.criteo_q = window.criteo_q || [];

var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

 window.criteo_q.push(

 { event: "manualFlush"},

 { event: "setAccount", account: TEST.COM ACCOUNT ID },

 { event: "setSiteType", type: deviceType },

 { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },

 { event: "viewBasket", item: [ { id: "TEST.COM PRODUCT ID", price: TEST.COM UNIT PRICE, quantity: TEST.COM PRODUCT QUANTITY }

 /* add a line for each product in the user's basket */

 ]},

 { event: "flushEvents"},

 { event: "setAccount", account: EXAMPLE.COM ACCOUNT ID },

 { event: "setSiteType", type: deviceType },

 { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },

 { event: "viewBasket", item: [ { id: "EXAMPLE.COM PRODUCT ID", price: EXAMPLE.COM UNIT PRICE, quantity: EXAMPLE.COM PRODUCT QUANTITY }

 /* add a line for each product in the user's basket */

 ]},

{ event: "flushEvents"}

);

</script>
```

If you manage multiple websites but they share the same Basket/Cart page, you will need to set-up a manual flush of events in the Criteo OneTag.   
  
For example, you have two websites, EXAMPLE.COM and TEST.COM, and they share the same Cart page test.com/cart. You will need to add the **manualFlush** event to the event, and **flushEvents** to each additional website purchased from.   
  
Example of manual flush implemented on the Criteo OneTag, on your Basket page is on the left.

This path ends here.

<a id="step-887073"></a>

## Event setup for multiple payment types

```javascript
<!-- //Criteo Loader --> 
<script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true">
</script>
 <!--............ --> 
 <script type="text/javascript"> 
 function load_Criteo_OneTag(){  
    window.criteo_q = window.criteo_q || [];  
    window.criteo_q.push(  
        { event: "setAccount", account: ##YOUR UNIQUE ACCOUNT ID## },  
        { event: "setSiteType", type: "m FOR MOBILE OR t FOR TABLET OR d FOR DESKTOP" },  
        { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },  
        { event: "trackTransaction", id: "TRANSACTION ID",  
        item: [ { 
            id: "FIRST PRODUCT ID", 
            price: ##FIRST PRODUCT UNIT PRICE##, 
            quantity: ##FIRST PRODUCT QUANTITY## },  
            { id: "SECOND PRODUCT ID", 
            price: ##SECOND PRODUCT UNIT PRICE##, 
            quantity: ##SECOND PRODUCT QUANTITY## }  
            /* add a line for each product in the user's basket */  
        ]}); } 
</script> 
<!--............ --> 
<button type="button" onclick="load_Criteo_OneTag()">PayPal</button>
```

The Criteo OneTag must be installed on the Order Confirmation page of your website regardless of the payment method selected by the user so that you can track the products bought.  

  
Tracking what the user buys allows Criteo to optimize the banner display so that products bought by the user won't be displayed to them again. If you have a different Order Confirmation page for each payment method, make sure the Criteo OneTag is implemented and working on each of those pages.

**Transactions outside of your domain**

If you offer any payment method where the transaction takes place outside of your domain, (such as PayPal) you may find that a significant number of your customers using that payment method are not being redirected back to your site. If they do not return to the Order Confirmation/Thank You page automatically, you may need to implement the Criteo OneTag on the Pay Now button that redirects to the external domain, so Criteo can capture the transaction.  
  
The example on the left shows how to implement the Criteo OneTag on a button called "PayPal". There is just one function to be added.  
  
**The Criteo OneTag implemented on a button to track external sales.**

Next: [How to avoid counting repeated transactions caused by multi-clicks](#step-4335430)

<a id="step-887078"></a>

## Event setup for travel advertisers

```javascript
<script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true"></script>

 <script type="text/javascript">

 window.criteo_q = window.criteo_q || [];

 window.criteo_q.push(

 { event: "setAccount", account: YOUR_UNIQUE_ACCOUNT_ID },

 { event: "setSiteType", type: "d" },

 { event: "setEmail", email: "criteotest@test.com" },

 { event: "viewSearch", checkin_date: "2016-08-12", checkout_date: "2016-08-18"},

 { event: "viewBasket", item: [ { id: "FLIGHT_ID1", price: 299.99, quantity: 1 }



 ]});

 </script>
```

If your website contains dates for a booking or for renting some product, then the **viewSearch event** can be beneficial to the performance of your campaign. Implementing the **viewSearch** event on your site allows Criteo to better understand the user's interest in booking/renting the desired trip/product.    

**viewSearch event**

  
The **viewSearch** event collects both a start and end date. These dates help the Criteo AI Engine better recommend products at the correct time before purchase. It also provides the information needed so that we do not serve irrelevant information to users who have already passed the dates of interest. 

  
**How to implement**

  
You simply need to add the following event to the Criteo OneTag on any page where dates are available, and then dynamically send the dates in the following format: _yyyy-MM-dd_

 `{ event: "viewSearch", checkin_date: "yyyy-MM-dd", checkout_date: "yyyy-MM-dd"}`

  
As an example, if the `viewSearch` event were included in the `Basket` event, it would appear as shown on the left.

This path ends here.

<a id="step-887077"></a>

## Less/more than 3 product IDs in the Criteo OneTag on search listing pages

A search listing page shows **multiple products**, like a **category page** or a s**earch result page**. Implementing Criteo OneTag on these pages allows Criteo to track the user's interest in a certain kind of product (e.g. products in a particular category).  
  
It is strongly recommended that you pass the top **three** product IDs within the Criteo OneTag on the search listing page. Alternatively, you can pass three product IDs of products shown on the page.

**More than three product IDs are being passed**

  
If more than three product IDs are passed, Criteo will only take the first three supplied IDs into account. For maximum performance, it is recommended that you only pass three IDs.

**Less than three product IDs are being passed**

  
If less than three IDs are passed, Criteo cannot analyze the user's intent correctly; this will negatively affect the performance of your campaign. Therefore, you should always pass three IDs into the Criteo OneTag.

The only exception to this rule would be for a search result that returns less than three products.

This path ends here.

<a id="step-887072"></a>

## Setup the netID integration

**European netID Foundation**

_"The European netID Foundation was established in March 2018 by Mediengruppe RTL Deutschland, ProSiebenSat.1 and United Internet AG._

_The foundation pursues_ **_the goal_** _of_ **_establishing netID as a European alternative to US single sign-on providers_**_. With the netID Privacy Center, users can organize their consent for Internet services transparently and in compliance with data protection regulations._

_For this purpose, the foundation has developed an open standard that enables users across all industries to access all the internet services from the foundation’s partners using the same login data."_  
  

**netID**

_"With their central netID account, users can easily and conveniently login to a large number of Internet services.  
Login and password, as well as their consent to use their data, are transparently organized in a Privacy Center – with the advantage that control over the data is completely and exclusively in the hands of the user.  
Users can change their consent in the Privacy Center at any time.  
netID thereby guarantees high-security standards and the greatest possible data sovereignty."_

Click [here](https://enid.foundation/en/netid/) to visit the official netID website.  
  

**netID integration with Onetag**

Dynamically replace fields surrounded by ##. See the table below for more info on the fields:

`<script type="text/javascript"> window.criteo_q = window.criteo_q || []; window.criteo_q.push({ event: 'setIdentity', identity: { source: "netid.de", uids: [{ id: "##NetID##" }] } }); </script>`  **  
setIdentity event**

This event should fire as any other event in the event queue.

This path ends here.

<a id="step-1948825"></a>

## SHA256 and MD5 (Preferred)

Criteo is migrating our identity graph from hashing our emails via MD5/SHA256MD5 to SHA256. To maximize match rates between your data and our identity graph, especially during the migration period, please share either legacy format (MD5 or SHA256MD5) alongside the new SHA256 format.

Here is an example of the SHA256 hashed email alongside an MD5 email sent in the **setEmail** event:

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "md5" }`

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "sha256" }`

> **Tip:** Before hashing, all users’ email addresses need to be:
>
> -   Trimmed; removed of all spaces before and after the user's email address.
>     
> -   Converted to lowercase.
>     
> -   Encoded in UTF-8.

The **setEmail** event should be added to all of the Criteo event tags that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion), so that the email is passed whenever your website has it available.

Shown in the below steps are examples of how this event looks in Criteo's Homepage tag with the combination of MD5 alongside SHA256, or the combination of SHA256MD5 alongside SHA256

- If "SHA256  alongside MD5": [Example](#step-1950389)
- If "SHA256 alongside SHA256MD5": [Example](#step-1950652)

<a id="step-1948824"></a>

## SHA256 hashed

Please use the **setEmail** event if you are passing SHA256 hashed emails.

Here is an example of a SHA256 hashed email sent in the **setEmail** event:

`{ event: "setEmail", email: "46a828eb4c5d239d631a15094c934cada1812d5fc22cd14155ca684832a70938", hash_method: "sha256" }`

> **Tip:** Before hashing, all users’ email addresses need to be:
>
> -   Trimmed; removed of all spaces before and after the user's email address.
>     
> -   Converted to lowercase.
>     
> -   Encoded in UTF-8.

The **setEmail** event should be added to all of the Criteo event tags that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion), so that the email is passed whenever your website has it available.

Shown in the below step is an example of how this event looks in Criteo's Homepage tag.

Next: [Example](#step-1950477)

<a id="step-1948817"></a>

## Plain text

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##"},
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

Please use the **setEmail** event if you are passing plain text emails.

In the event that a plain email address is sent, Criteo will then encrypt the user's email address automatically before it is saved in our database. Here is an example of the plain-text email sent in the **setEmail** event:

`{ event: "setEmail", email: "user@example.com" },`

  
In the event that you are unable to pass either an unhashed or hashed email address, please simply pass us an empty string:

`{ event: "setEmail", email: "" },`

> **Warning:** In some countries, it is not allowed to pass clear-text email addresses to third parties due to local legislation regardless of whether the data is hashed before storage. While Criteo recommends always hashing any user information before sharing it with us, sharing clear-text emails is also an option. However, it is up to clients to be aware of the laws in effect and decide the best approach for their business and the market(s) they operate, in case they decide to share non-hashed information.

> **Tip:** When passing plain text, all users’ email addresses need to be:
>
> -   Trimmed; removed of all spaces before and after the user's email address.
>     
> -   Converted to lowercase.
>     
> -   Encoded in UTF-8.

The **setEmail** event should be added to all of the Criteo event tags that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion), so that the email is passed whenever your website has it available.

This path ends here.

<a id="step-1950390"></a>

## MD5 or SHA256MD5 (Legacy)

Please use the **setEmail** event if you are passing MD5 or SHA256MD5 hashed emails.

Here is an example of an MD5 hashed email sent in the **setEmail** event:

`{ event: "setEmail", email: "f3ada405ce890b6f8204094deb12d8a8", hash_method: "sha256" }`

Here is an example SHA256MD5 sent in the **setEmail** event:

`{ event: "setEmail", email: "0fb0ecec887b92bd4a793669f9a52e8c2af81cdf8a59bc7399c9bc910853fb66", hash_method: "sha256_md5" },`

> **Tip:** Before hashing, all users’ email addresses need to be:
>
> -   Trimmed; removed of all spaces before and after the user's email address.
>     
> -   Converted to lowercase.
>     
> -   Encoded in UTF-8.

The **setEmail** event should be added to all of the Criteo event tags that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion) so that the email is passed whenever your website has it available.

The below step shows an example of how this event looks in Criteo's Homepage tag.

- If "MD5 Hashed": [Example](#step-1958150)
- If "SHA256MD5 Hashed": [Example](#step-1958151)

<a id="step-1948827"></a>

## Hashing functions

If you are hashing the user's email address before it is passed to Criteo, you can use one of the following functions to ensure proper encryption.

- If "SHA256 Hashing Function using JavaScript": [SHA256 Hashing Function using JavaScript](#step-1957333)
- If "SHA256 Hashing function using C\#": [SHA256 Hashing function using C\#](#step-1951709)
- If "SHA256 Hashing function using Java": [SHA256 Hashing function using Java](#step-1951710)
- If "SHA256 Hashing function using Perl": [SHA256 Hashing function using Perl](#step-1951708)
- If "SHA256 Hashing function using PHP": [SHA256 Hashing function using PHP](#step-1951742)
- If "MD5 Hashing function using PHP": [MD5 Hashing function using PHP](#step-1951849)
- If "MD5 Hashing function using C\#": [MD5 Hashing function using C\#](#step-1951850)
- If "MD5 Hashing Function using Java": [MD5 Hashing Function using Java](#step-1951851)
- If "MD5 hashing function using JS": [MD5 hashing function using JS](#step-3858724)

<a id="step-1948826"></a>

## FAQ

**Do I need to update my website's privacy policy?**

You need to ensure your Website Privacy Policy clearly informs your website visitors that email addresses may be collected and shared with third-parties that you collaborate with to optimize campaign performance and that this information is hashed using the latest and most secure SHA256 hashing technology. As such, no PII data is shared with third parties.

Additionally, you should inform your visitors that you respect their privacy, and should they prefer not to share such information, they can do so by selecting their preferred options in your website user cookie compliance banner (CMP).

Please refer to [Criteo's Privacy Policy](https://help.criteo.com/kb/guide/en/the-criteo-privacy-promise-pDIW4yiawH/Steps/775742) for more information, and you may also include the provided link within your website's Privacy Policy section. 

> **Tip:** Should your legal team have any concerns relating to privacy, they may reach out to your Criteo business contact who will connect them with our legal team as needed.

**I am already passing email hashed in MD5 format in my tags, what should I do?**

You should continue to pass this way and ensure the "hash-method" parameter is set to "md5". Note that Criteo takes this string and encodes it via SHA256 additionally before we store it.

Then you should add an additional '**setEmail**' event, in all of your Criteo tags, to pass in SHA256 as well. When this additional event is added, please ensure the "hashed\_method" parameter is set to "sha256", for example:

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "md5" }`

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "sha256" }`

**I am already passing email hashed in SHA256MD5 format in my tags, what should I do?**

You should continue to pass this way and ensure the "hash-method" parameter is set to "md5". Note that Criteo takes this string and SHA256 hash-encodes it additionally before storing.

Then you should add an additional '**setEmail**' event, in all of your Criteo tags, to pass in SHA256 as well. When this additional event is added, please ensure the "hashed\_method" parameter is set to "sha256", for example:

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "sha256_md5" }`

`{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "sha256" }`

**I only have the ability to pass email hashed in SHA256, what should I do?**

There is no need for changes. Please ensure the "hash\_method" parameter is set to "sha256", for example:

  `{ event: "setEmail", email: "##Hashed Email Address##", hash_method: "sha256" }`

This path ends here.

<a id="step-4106563"></a>

## SHA256

```javascript
<!-- Criteo Homepage Tag -->
<script type="text/javascript">
  window.criteo_q = window.criteo_q || [];
  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";
  window.criteo_q.push(
    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256" },
    { event: "setSha256HashedPhoneNumber", phone_number: "fda66831d0cb0eb4bffb21bc795308d69921c211c57be0ae15702071e3b9e989" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }
  );
</script>
```

As phone numbers are a sensitive PII, Criteo accepts hashed phone numbers from partners and encourages it. 

Expected underlying phone numbers format is a trimmed [E.164](https://en.wikipedia.org/wiki/E.164) format including the country code, without the leading "+" sign (so only 15 digits, at most): sha256(internationalPhoneNumber.replaceAll(/\[^0-9\]/g, "")).

**Examples:**

-   1 (234) 567-8910 → sha256(12345678910) → 63640264849a87c90356129d99ea165e37aa5fabc1fea46906df1a7ca50db492
    
-   81-12-3456-7891 → sha256(811234567891) → d9825fb05347d3c910fc5202c0c20d07a87b791cc643c6f2d70402394a849540
    
-   02 1234 5678 → sha256(0212345678) → 826f54894e28f3f1795f3c5e3335cf98709c5d5b38b3f9c6d72467d491f032df
    
-   +33 1 40 40 22 90 → sha256(33140402290) → fda66831d0cb0eb4bffb21bc795308d69921c211c57be0ae15702071e3b9e988
    

Please use the **setSha256HashedPhoneNumber** event if you are passing SHA256 hashed phone numbers. Here is an example of the SHA256 hashed phone number sent in the setSha256HashedPhoneNumber event:

`{ event: "setSha256HashedPhoneNumber", phone_number: "fda66831d0cb0eb4bffb21bc795308d69921c211c57be0ae15702071e3b9e989" }`

The **setSha256HashedPhoneNumber** event should be added to **all of the Criteo event tags** that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion), so that the phone number is passed whenever your website has it available.

Examples of how this event looks in Criteo's Homepage tag is visible on the left side.

This path ends here.

<a id="step-4106562"></a>

## Plain Text

```javascript
<!-- Criteo Homepage Tag -->
<script type="text/javascript">
  window.criteo_q = window.criteo_q || [];
  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";
  window.criteo_q.push(
    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256" },
    { event: 'setPhoneNumber', phone_number: '+33 (0) 1 40 40 22 90' },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }
  );
</script>
```

**In the event that a plain phone number is sent, Criteo will encrypt the user’s phone number automatically before it is saved in our database.**

On Criteo's side we will validate and normalize the numbers collected. Any international formats are accepted (including the leading "+" sign). Normalization removes all non numeric characters.

**Validation checks:**

-   Number starts with a + sign
    
-   length is at most 15 digits
    
-   there is no leading 0: many countries use 0 as national dial number
    

**Examples:**

-   +1 (234) 567-8910
    
-   +81-12-3456-7891
    
-   +33 1 40 40 22 90
    
-   02 1234 5678 is **rejected** because of a leading 0 indicating that it is a national phone number
    

As with other ids, phone numbers will be hashed before being stored. Criteo's backend maps the clear phone numbers to SHA256 HPN so the two accepted formats are uniform. Criteo doesn't have access to any phone number shared with us.  

> **Tip:** Although clear-text phone numbers are accepted, **it's highly recommended to use the SHA-256 hash** when sharing any type of user information.

> **Tip:** **Note:** In some countries, it is not allowed to pass clear-text phone numbers to third parties due to local legislation, regardless of whether the data is hashed before storage. While Criteo recommends always hashing any user information before sharing it with us, sharing clear-text phone numbers is also an option. However, you must be aware of the laws in effect and decide the best approach for your business and the market(s) you operate, in case you decide to share non-hashed information.

Please use the **setPhoneNumber** event if you are passing plain text phone numbers. Here is an example of a plain phone number sent in the setPhoneNumber event:

`{ event: 'setPhoneNumber', phone_number: '+33 (0) 1 40 40 22 90' }`

The **setPhoneNumber** event should be added to **all of the Criteo event tags** that are on your website (e.g. Homepage, Product. AddToCart, Basket, Sales/Conversion), so that the phone number is passed whenever your website has it available.  
  
Examples of how this event looks in Criteo's Homepage tag is shown on the left.

This path ends here.

<a id="step-4335430"></a>

## How to avoid counting repeated transactions caused by multi-clicks

```javascript
<!-- //Criteo Loader --> 
 <script type="text/javascript" src="//dynamic.criteo.com/js/ld/ld.js?a=YOUR_PARTNER_ID" async="true">
</script> 
<!-- // Declare the variable --> 
<script type="text/javascript">  
    var cto_clicked = false; 
</script> 
<!--............ --> 
<script type="text/javascript"> 
function load_Criteo_OneTag(){  
    if (!window.cto_clicked){  
        window.clicked = true;  
        window.criteo_q = window.criteo_q || [];  
        window.criteo_q.push(  
            { event: "setAccount", account: ##YOUR UNIQUE ACCOUNT ID## },  
            { event: "setSiteType", type: "m FOR MOBILE OR t FOR TABLET OR d FOR DESKTOP" },  
            { event: "setEmail", email: "TRIMMED AND LOWERCASE USER EMAIL ADDRESS" },  
            { event: "trackTransaction", id: "TRANSACTION ID",  
            item: [ 
                { id: "FIRST PRODUCT ID", 
                price: ##FIRST PRODUCT UNIT PRICE##, 
                quantity: ##FIRST PRODUCT QUANTITY## },  
                { id: "SECOND PRODUCT ID", 
                price: ##SECOND PRODUCT UNIT PRICE##, 
                quantity: ##SECOND PRODUCT QUANTITY##} 
                 /* add a line for each product in the user's basket */  
            ]});  } } 
</script> 
<!--............ --> 
<button type="button" onclick="load_Criteo_OneTag()">PayPal</button>
```

Sometimes users will double-click the Pay Now button that redirects to the external payment method. To avoid executing the Criteo OneTag each time the user clicks, you can add a variable that prevents the event from being executed more than once.  
  
**The Criteo OneTag implemented on a Sales Confirmation page with multi-click detection is on the left.**

Next: [Generating a random Transaction ID](#step-4335431)

<a id="step-1950389"></a>

## Example

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256" },
    { event: "setEmail", email: "##Email Address##", hash_method: "md5" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

This path ends here.

<a id="step-1950652"></a>

## Example

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256" },
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256_md5" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

This path ends here.

<a id="step-1950477"></a>

## Example

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

This path ends here.

<a id="step-1958150"></a>

## Example

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "md5" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

This path ends here.

<a id="step-1958151"></a>

## Example

```javascript
<!-- Criteo Homepage Tag -->

<script type="text/javascript">

  window.criteo_q = window.criteo_q || [];

  var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

  window.criteo_q.push(

    { event: "setAccount", account: YOUR_PARTNER_ID},
    { event: "setEmail", email: "##Email Address##", hash_method: "sha256_md5" },
    { event: "setSiteType", type: deviceType},
    { event: "setCustomerId", id: "##Customer Id##" },
    { event: "setRetailerVisitorId", id: "##Visitor Id##"},
    { event: "setZipcode", zipcode: "##Zip Code##" },
    { event: "viewHome" }

  );

</script>

<!-- END Criteo Homepage Tag -->
```

This path ends here.

<a id="step-1957333"></a>

## SHA256 Hashing Function using JavaScript

```javascript
async function sha256(message) {
  // encode as UTF-8
  const msgBuffer = new TextEncoder('utf-8').encode(message);

  // hash the message
  const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);

  // convert ArrayBuffer to Array
  const hashArray = Array.from(new Uint8Array(hashBuffer));

  // convert bytes to hex string
  const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
  return hashHex;
}

function format(email) {
	return email.toLowerCase().trim();
}

var email = "   uSèr@example.Com   ";
//CHANGE BASED ON WHAT YO USUALLY PUT AS EXAMPLE
var hemPromise = sha256(format(email));
hemPromise.then(hem => console.log(hem));
```

This path ends here.

<a id="step-1951709"></a>

## SHA256 Hashing function using C\#

```text/x-csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace Sample_EmailHashing_code {
  public class CriteoHashedEmailFormatter {
    private static SHA256 _sha256;
    private static SHA256 Sha256 {
      get {
        return _sha256 ?? (_sha256 = SHA256.Create());
      }
    }
    private static string Sha256Encode(string sourceString) {
      byte[] inputBytes = Encoding.UTF8.GetBytes(sourceString);
      byte[] hash = Sha256.ComputeHash(inputBytes);
      var sb = new StringBuilder(32);
      foreach(byte b in hash) sb.Append(b.ToString("x2"));
      return sb.ToString();
    }
    public static string HashEmail(string sourceEmail) {
      String processedEmail;
      processedEmail = sourceEmail.ToLowerInvariant(); //conversion to lower case
      processedEmail = processedEmail.Trim(); //trimming leading and trailing spaces
      processedEmail = Sha256Encode(processedEmail); //conversion to UTF-8 and hashing with SHA256
      return processedEmail;
    }
  }
  class SampleEmailHashing {
    static void Main(string[] args) {
      String sourceEmail = "   uSèr@example.Com   ";
      String processedEmail = CriteoHashedEmailFormatter.HashEmail(sourceEmail);
      Console.WriteLine(processedEmail);
      Console.ReadKey();
    }
  }
}
```

This path ends here.

<a id="step-1951710"></a>

## SHA256 Hashing function using Java

```text/x-java
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SampleEmailHashing {
  public static void main(String[] args) {
    String sourceEmail = new String(" uSèr@example.Com ");
    String processedEmail = FormatMail(sourceEmail);
    System.out.println(processedEmail);
  } //Method to format the source Email, converting to lower case and removing spaces               
  private static String FormatMail(String mail) {
    String newMail = new String(mail);
    // conversion to lower case characters          
    newMail = newMail.toLowerCase();
    //remove empty spaces          
    newMail = newMail.trim();
    newMail = sha256Java(newMail);
    return newMail;
  } //Method to encrypt email address using MD5      
  public static String sha256Java(String message) {
    String digest = null;
    try { //conversion to UTF-8 and hashing with SHA256
      MessageDigest md = MessageDigest.getInstance("SHA256");
      byte[] hash = md.digest(message.getBytes("UTF-8"));
      StringBuilder sb = new StringBuilder(2 * hash.length);
      for (byte b: hash) {
        sb.append(String.format("%02x", b & 0xff));
      }
      digest = sb.toString();
    } catch (UnsupportedEncodingException ex) {
      ex.printStackTrace();
    } catch (NoSuchAlgorithmException ex) {
      ex.printStackTrace();
    }
    return digest;
  }
}
```

This path ends here.

<a id="step-1951708"></a>

## SHA256 Hashing function using Perl

```perl
#!/usr/bin/perl  

 use strict;  

 use warnings;  

 use Digest::SHA256 qw(sha256 sha256_hex);  

 use Encode;  

 my $original_email  = qw/ uSèr@example.Com /;  

 my $processed_email = lc($original_email);     

    $processed_email =~ s/^\s+//;     

    $processed_email =~ s/\s+$//;     

    $processed_email = encode_utf8($processed_email);     

    $processed_email = sha256_hex($processed_email);  

 print "Original email:\t$original_email\n";  

 print "Hashed email:\t$processed_email \n"; 
```

This path ends here.

<a id="step-1951742"></a>

## SHA256 Hashing function using PHP

```php
$source_address = "uSèr@example.Com "; 
$processed_address = strtolower($source_address); //convert address to lower case 
$processed_address = trim($processed_address); //trimming leading and trailing spaces
$processed_address = mb_convert_encoding($processed_address, "UTF-8", "ISO-8859-1"); //conversion from ISO-8859-1 to UTF-8 (replace "ISO-8859-1" with the source encoding of your string) 
$processed_address = hash('sha256', $processed_address, false); //hash address with SHA256 algorithm 
echo "Source e-mail: ".$source_address." | Hashed e-mail: ".$processed_address;
```

This path ends here.

<a id="step-1951849"></a>

## MD5 Hashing function using PHP

```php
$source_address = "uSèr@example.Com "; 
$processed_address = strtolower($source_address); //convert address to lower case 
$processed_address = trim($processed_address); //trimming leading and trailing spaces 
$processed_address = mb_convert_encoding($processed_address, "UTF-8", "ISO-8859-1"); //conversion from ISO-8859-1 to UTF-8 (replace "ISO-8859-1" with the source encoding of your string) 
$processed_address = hash('md5', $processed_address, false); //hash address with SHA256 algorithm 
echo "Source e-mail: ".$source_address." | Hashed e-mail: ".$processed_address;
```

This path ends here.

<a id="step-1951850"></a>

## MD5 Hashing function using C\#

```text/x-csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace Sample_EmailHashing_code {
  public class CriteoHashedEmailFormatter {
    private static MD5 _md5;
    private static MD5 Md5 {
      get {
        return _md5 ?? (_md5 = MD5.Create());
      }
    }
    private static string Md5Encode(string sourceString) {
      byte[] inputBytes = Encoding.UTF8.GetBytes(sourceString);
      byte[] hash = Md5.ComputeHash(inputBytes);
      var sb = new StringBuilder(32);
      foreach(byte b in hash) sb.Append(b.ToString("x2"));
      return sb.ToString();
    }
    public static string HashEmail(string sourceEmail) {
        String processedEmail;
        processedEmail = sourceEmail.ToLowerInvariant(); //conversion to lower case              
        processedEmail = processedEmail.Trim(); //trimming leading and trailing spaces              
        //conversion to UTF-8 and hashing with SHA256              
        processedEmail = Md5Encode(processedEmail);              
        return processedEmail;          
    }      
  }      
  class SampleEmailHashing      {          
    static void Main(string[] args)          {              
      String sourceEmail = "   uSèr@example.Com   ";              
      String processedEmail = CriteoHashedEmailFormatter.HashEmail(sourceEmail);              
      Console.WriteLine(processedEmail);              Console.ReadKey();          
    }      
  }  
}
```

This path ends here.

<a id="step-1951851"></a>

## MD5 Hashing Function using Java

```clike
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SampleEmailHashing {
  public static void main(String[] args) {
    String sourceEmail = new String(" uSèr@example.Com ");
    String processedEmail = FormatMail(sourceEmail);
    System.out.println(processedEmail);
  } //Method to format the source Email, converting to lower case and removing spaces               
  private static String FormatMail(String mail) {
    String newMail = new String(mail);
    // conversion to lower case characters          
    newMail = newMail.toLowerCase();
    //remove empty spaces          
    newMail = newMail.trim();
    newMail = md5Java(newMail);
    return newMail;
  } //Method to encrypt email address using MD5      
  public static String md5Java(String message) {
    String digest = null;
    try { //conversion to UTF-8 and hashing with MD5
      MessageDigest md = MessageDigest.getInstance("MD5");
      byte[] hash = md.digest(message.getBytes("UTF-8"));
      StringBuilder sb = new StringBuilder(2 * hash.length);
      for (byte b: hash) {
        sb.append(String.format("%02x", b & 0xff));
      }
      digest = sb.toString();
    } catch (UnsupportedEncodingException ex) {
      ex.printStackTrace();
    } catch (NoSuchAlgorithmException ex) {
      ex.printStackTrace();
    }
    return digest;
  }
}
```

This path ends here.

<a id="step-3858724"></a>

## MD5 hashing function using JS

```javascript
// md5 function should be provided by the client (by installing a 3rd party one)

function format(email) {
	return email.toLowerCase().trim();
}

var email = "   uSèr@example.Com   ";
var hemPromise = md5(format(email));
hemPromise.then(hem => console.log(hem));
```

> **Tip:** **Important**
>
> Make sure to install this external library [https://www.md5.cz/javascript-md5](https://www.md5.cz/javascript-md5b) before you implement the code in the page.

This path ends here.

<a id="step-4335431"></a>

## Generating a random Transaction ID

```javascript
<!--............ --> 
{ event: "trackTransaction", 
    id: "PayPal_" + Math.floor(Math.random()*9999999),  
    item: [ 
        { id: "FIRST PRODUCT ID", 
        price: ##FIRST PRODUCT UNIT PRICE##, 
        quantity: ##FIRST PRODUCT QUANTITY## },  
        { id: "SECOND PRODUCT ID", 
        price: ##SECOND PRODUCT UNIT PRICE##, 
        quantity: ##SECOND PRODUCT QUANTITY## }  
        /* add a line for each product in the user's basket */ 
    ]}); 
<!--............ -->  
```

In the event that the order does not have an associated Transaction ID to pass into the Criteo OneTag when the user clicks on the Pay Now button, you can use this random function to generate one.  
  
**Random function:**  
  
 Math.floor(Math.random()\*9999999)  
  
In the example below, this random function is combined with the prefix "Button\_" in order to create a Transaction ID that is more easily identified. Where you use multiple payment options you can change the word "Button" for the method selected by the user. For example, if you implemented this code on a button that redirects to PayPal, you can use "PayPal\_" instead of "Button\_" so it is even easier to identify the transaction.  
  
Note that the code on the left is just an extract of the trackTransaction event of the Criteo OneTag in order to highlight the portion relating to the Transaction ID.  
  
**The Criteo OneTag implemented on a Sales Confirmation page on the left.**

This path ends here.
