---
title: 'Criteo Tagの詳細設定'
description: 'いくつかの高度な設定を有効にするために、Criteo Tagの実装に変更を加えることができます。 これにより、クロスデバイスでのターゲティング、複数の通貨/国で展開する広告主、その他のトピックに対応可能になります。以下の目次を読んで、お客様が最適な設定を行う方法を確認してください。'
language: ja
guide: M2TiX6m90K
updated: 2025-11-12T13:21:16Z
canonical: https://help.criteo.com/kb/guide/ja/criteo-tag-M2TiX6m90K/Steps/886908
alternates:
  de: https://help.criteo.com/kb/guide/de/erweiterte-einstellungen-von-criteo-onetag-M2TiX6m90K.md
  en: https://help.criteo.com/kb/guide/en/criteo-onetag-advanced-settings-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
  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/ja/criteo-tag-M2TiX6m90K/Steps/886908

# Criteo Tagの詳細設定

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

## Criteo Tagの詳細設定

いくつかの高度な設定を有効にするために、Criteo Tagの実装に変更を加えることができます。  
  
これにより、クロスデバイスでのターゲティング、複数の通貨/国で展開する広告主、その他のトピックに対応可能になります。以下の目次を読んで、お客様が最適な設定を行う方法を確認してください。

- If "クロスデバイスイベントの設定": [クロスデバイス イベントを介してハッシュ化されたメールを渡す](#step-887075)
- If "Pass phone numbers with OneTag": [Pass phone numbers with OneTag](#step-4106561)
- If "さまざまなサイトタイプのイベント設定": [さまざまなサイトタイプのイベント設定](#step-887074)
- If "複数の国のイベント設定": [複数の国のイベント設定](#step-887076)
- If "複数の通貨のイベント設定": [複数の通貨のイベント設定](#step-887079)
- If "同じバスケット/カートを使用する複数のウェブサイトのイベント設定": [同じバスケット/カートを使用する複数のウェブサイトのイベント設定](#step-887071)
- If "複数の支払いタイプのイベント設定": [複数の支払いタイプのイベント設定](#step-887073)
- If "旅行広告主のイベント設定": [旅行広告主のイベント設定](#step-887078)
- If "検索一覧ページのCriteo Tagの3つ以下の商品ID": [検索一覧ページのCriteo Tagの3つ以下の商品ID](#step-887077)
- If "netID統合の設定 欧州netID財団": [netID統合の設定 欧州netID財団](#step-887072)

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

## クロスデバイス イベントを介してハッシュ化されたメールを渡す

Criteo OneTag 内にクロスデバイス パラメータを実装することは、次の場合に不可欠です。

-   現在、Safari と Firefox でアドレス指定可能なオーディエンスにリーチし、Chrome でのサードパーティ Cookie の廃止に向けて準備しています。
    
-   クロスデバイス機能の有効化: 潜在的な顧客がモバイル デバイスから Web サイトで製品を閲覧している場合、このパラメーターを使用すると、後でこの顧客に関連する広告をデスクトップ デバイスに表示できます。
    
-   連絡先リストを Commerce Growth にアップロードするか、API 経由で送信すると、一致率が向上します。
    

**使い方**

クロスデバイス パラメータは、訪問者のハッシュ化された電子メール アドレスを Web サイトに渡すための小さなコード スニペットです。すべてのメール アドレスは、Criteo のサーバーに保存される前に、SHA-256 アルゴリズムを使用してハッシュされます。次に、Criteo はハッシュ値を使用して、各デバイス間でユーザーを照合します。  
  
顧客のプライバシーを確実に保護するために、Criteo は顧客のハッシュ化された電子メール アドレスのみをサーバーに保存します。  

**ウェブサイトのプライバシー ポリシーを更新する必要がありますか?**

ウェブサイトのプライバシー ポリシーで、電子メール アドレスが収集され、キャンペーンのパフォーマンスを最適化するために協力するサード パーティと共有される可能性があること、およびこの情報が最新かつ最も安全な SHA256 ハッシュ テクノロジを使用してハッシュされることを、ウェブサイトの訪問者に明確に通知する必要があります。

さらに、プライバシーを尊重することを訪問者に通知する必要があります。訪問者がそのような情報を共有したくない場合は、Web サイトのユーザー Cookie コンプライアンス バナー (CMP) で希望するオプションを選択することで共有できます。

詳細については、 [Criteo のプライバシー ポリシー](https://help.criteo.com/kb/guide/en/the-criteo-privacy-promise-pDIW4yiawH/Steps/775742)を参照してください。ウェブサイトのプライバシー ポリシー セクションに提供されたリンクを含めることもできます。

> **Tip:** 法務チームがプライバシーに関する懸念を持っている場合、Criteo のビジネス担当者に連絡し、必要に応じて Criteo の法務チームにつなげることができます。

**クロスデバイス パラメータの実装方法**

最大限の柔軟性を提供するために、Criteo は次の形式のユーザーの電子メール アドレスを受け入れます。

-   **SHA256 ハッシュ**(アドレサブル広告の業界標準に準拠)。
    
-   **MD5**または**SHA256MD5 ハッシュ**(Criteo の従来の方法)。
    
-   **プレーン テキスト**(その後、メールで SHA256 暗号化を使用します)。
    

> **Tip:** **注**: Criteo は、MD5/SHA256MD5 を介したメールのハッシュ化から SHA256 への移行を進めています。データと ID グラフの一致率を最大化するために、特に移行期間中は**、新しい SHA256 形式とともに従来の形式 (MD5 または SHA256MD5) を共有してください**。
>
> 両方を共有できない場合は**、SHA256 形式を優先して**ください。
>
> プレーン テキストを共有している場合、更新は必要ありません。

クロスデバイス パラメータを実装する各方法の詳細:

- If "SHA256 および MD5 (推奨)": [SHA256 および MD5 (推奨)](#step-1948825)
- If "SHA256 ハッシュ": [SHA256 ハッシュ](#step-1948824)
- If "平文": [平文](#step-1948817)
- If "MD5 または SHA256MD5 (レガシー)": [MD5 または SHA256MD5 (レガシー)](#step-1950390)
- If "ハッシュ関数": [ハッシュ関数](#step-1948827)
- If "よくある質問": [よくある質問](#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>

## さまざまなサイトタイプのイベント設定

```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>
```

動的なsetSiteTypeパラメータは、サイトのすべてのページに埋め込まれたCriteo Tag内にあります。お客様のサイトがさまざまなデバイスをサポートするために異なるバージョンを持っている場合は、「**setSiteType**」パラメーターを使用して、ユーザーに表示するバージョンを指定します。

-   **d** （PCサイトの場合）
-   **m** （モバイルの場合）
-   **t** （タブレットの場合）

例:  
  
PCサイト用のsetSiteTypeパラメータ:

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

  
モバイルサイト用のsetSiteTypeパラメータ: 

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

  
タブレットサイト用のsetSiteTypeパラメータ:  
 

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

この値を動的に送信できない場合は、次のスクリプトを使用して、ユーザーがデスクトップ、モバイル、またはタブレットのどちらにいるかを自動的に検出できます。  
 

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

  

次に、**deviceType**変数をイベントに配置する必要があります。したがって、「**setSiteType**」パラメータは次のようになります。

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

ホームページイベントは次のようになります。例:

This path ends here.

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

## 複数の国のイベント設定

```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>
```

ウェブサイトで複数の国の顧客に商品を販売している場合は、国ごとにCriteo**アカウントID**を動的に切り替える必要があります。 

以下の例では、追加の変数**criteo\_ID**がホームページイベントに追加されていることを確認できます。この変数の値は、ユーザーが選択した国に基づいて、固有の**#Country Account ID#**に値を動的に更新する必要があります。このロジックは、ウェブサイト上のCriteo Tagの各インスタンスに追加する必要があります。

Criteo Tagに実装された国固有のアカウントIDの例:

<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: "ハッシュ化されたメールアドレス", hash\_method: "sha256" },      

         { event: "viewHome"}

 );

</script>

This path ends here.

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

## 複数の通貨のイベント設定

ユーザーがウェブサイトで商品を異なる通貨で購入できる場合（たとえば、ユーザーが世界中から予約をしている旅行ウェブサイト）、購入する商品の通貨を定義することができます。

  
通貨を定義すると、Criteoのレポートに正しいキャンペーン通貨が表示され、独自のレポートに合わせることができます。  
  
商品価格はカートイベントとトランザクションイベントでのみ渡されるため、この機能はCriteo Tagのこれら2つのイベントでのみ使用してください。また、商品を1つの通貨でのみ販売する場合、この機能は使用しないでください。  
  
この機能は、有効なISO通貨コードのみを受け入れます（詳細: [https://www.iso.org/iso-4217-currency-codes.html](https://www.iso.org/iso-4217-currency-codes.html))。

  
入力は通貨コードに対応する有効な3文字の文字列でなければなりません（例: 「EUR」、「USD」、「JPY」...）。

-   ISO通貨コード
    -   3文字の文字列
    -   有効な通貨コード（例: 「EUR」、「USD」、「BRL」...）
-   大文字
    -   「JPY」（大文字）は有効な入力ですが、「jpy」（小文字）は無効です。

  
使い方

ユーザーがサイトで選択した通貨の3文字の文字列を入力します。価格の値は、サイトに表示される正確な数値である必要があります。ユーザーがUSDを選択し、価格が$100の場合、Criteo Tagの価格は100で、通貨はUSDである必要があります。  
  
**構文**

通過のパラメータは**currency**と呼ばれ、次のようになります。

currency: "JPY"  
  
これは、**カート（バスケット）イベント**のパラメータの例です:

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

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

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

\]} 

  
**コンバージョンイベント**のパラメータの例です:

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

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

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

\]} 

  
 

テストする方法

F12キーを押して、ブラウザのデバッグツールを開きます。\[ネットワーク\]タブで「criteo」を検索し、バスケット（カート）ページまたは販売確認ページ（通貨機能を実装した場所）に移動します。クエリ文字列パラメータには次のように表示されます:

This path ends here.

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

## 同じバスケット/カートを使用する複数のウェブサイトのイベント設定

```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>
```

複数のウェブサイトを管理していて、それらが同じカート（バスケット）ページを共有している場合、Criteo Tagでイベントの手動フラッシュ(flush)を設定する必要があります。

  
たとえば、EXAMPLE.COMとTEST.COMの2つのウェブサイトがあり、同じバスケット（カート）ページ「test.com/cart」を共有しているとします。イベントに**manualFlush**イベントを追加し、購入した各追加ウェブサイトに**flushEvents**を追加する必要があります。  
  
カート（バスケット）ページのCriteo Tagに実装された手動フラッシュの例:

<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: "
ハッシュ化されたメールアドレス", hash\_method:"sha256" },

 { 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: "
ハッシュ化されたメールアドレス", hash\_method:"sha256" },

 { 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>

This path ends here.

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

## 複数の支払いタイプのイベント設定

```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>
```

Criteo Tagは、購入した商品をトラッキングできるように、ユーザーが選択した支払い方法に関係なく、ウェブサイトの注文確認ページにインストールする必要があります。

  
ユーザーが購入したものをトラッキングすると、Criteoはバナー表示を最適化できるため、ユーザーが購入した商品が再び表示されることはありません。お支払い方法ごとに異なる注文確認ページがある場合は、Criteo Tagが実装されており、それらの各ページで機能していることを確認してください。

ドメイン外のトランザクション

ドメイン外で取引が行われるお支払い方法（PayPalなど）を提供している場合、そのお支払い方法を使用しているかなりの数の顧客がサイトにリダイレクトされないことがあります。注文確認/Thank youページに自動的に戻らない場合は、Criteoがトランザクションをキャプチャできるように、外部ドメインにリダイレクトする\[今すぐ支払う\]ボタンにCriteo Tagを実装する必要がある場合があります。  
  
以下の例は、「PayPal」というボタンにCriteo Tagを実装する方法を示しています。追加する関数は1つだけです:  
  
**外部販売をトラッキングするためのボタンに実装されたCriteo Tag**

 <!-- //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: "
ハッシュ化されたメールアドレス", hash\_method:
"sha256" },

 { 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>

**複数クリックによる繰り返されたトランザクションのカウントを回避する方法**  
  
ユーザーが外部の支払い方法にリダイレクトする\[今すぐ支払う\]ボタンをダブルクリックする場合があります。ユーザーがクリックするたびにCriteo Tagが実行されないように、イベントが複数回実行されないようにする変数を追加できます。  
  
以下の例をご覧ください:  
  
**複数クリック検出機能付きの販売確認ページに実装されたCriteo Tag:**  

 <!-- //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: "
ハッシュ化されたメールアドレス", hash\_method:
"sha256" },

 { 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>

**ランダムなトランザクションIDの生成**  
  
ユーザーが\[今すぐ支払う\]ボタンをクリックしたときに注文にCriteo Tagに渡されるトランザクションIDが関連付けられていない場合、このランダム関数を使用して生成できます。  
  
**ランダム関数:**  
  
Math.floor(Math.random()\*9999999)  
  
以下の例では、このランダム関数をプレフィックス「Button\_」と組み合わせて、より簡単に識別できるトランザクションIDを作成しています。複数の支払いオプションを使用する場合、ユーザーが選択した方法の「Button」という単語を変更できます。たとえば、PayPalにリダイレクトするボタンにこのコードを実装した場合、「Button\_」の代わりに「PayPal\_」を使用できるため、トランザクションを識別しやすくなります。  
  
以下のコードは、トランザクションIDに関連する部分を強調するための、Criteo TagのtrackTransactionイベントの抜粋であることに注意してください。  
  
**販売確認ページに実装されたCriteo Tag:**   

{ event: "trackTransaction", id: "PayPal\_" + Math.floor(Math.random()\*9999999),

 item: \[ { id: "FIRST PRODUCT ID", price: FIRST PRODUCT UNIT PRICE, quantity: FIRST PRODUCT QUANTITY },

 { id: "2番目の商品ID", price: 2番目の商品単価, quantity: 2番目の商品の数量 }

 /\* ユーザーのカート内にあるアイテムごとに1行ずつ追加します \*/

\]});

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

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

## 旅行広告主のイベント設定

```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>
```

ウェブサイトに予約や商品のレンタルの日付が含まれている場合、**viewSearchイベント**はキャンペーンのパフォーマンスに役立つ可能性があります。サイトに**viewSearchイベントを実装すると、Criteoは、ユーザーが目的の旅行/商品を、予約/レンタルをすることへの興味・関心をよりよく理解できます。**  

viewSearchイベント

  
**viewSearch**イベントは、開始日と終了日の両方を収集します。これらの日付は、Criteo AIエンジンが購入前の正しいタイミングで商品をより適切におすすめするのに役立ちます。また、興味・関心のある日付をすでに過ぎてしまったユーザーに無関係な情報を提供しないようにするための、必要な情報も提供します。 

  
実装方法

  
日付を使用できるページのCriteo Tagに次のイベントを追加し、日付を次の形式で動的に送信するだけです: _yyyy-MM-dd  
  
_

 { event: "viewSearch", checkin\_date: "yyyy-MM-dd", checkout\_date: "yyyy-MM-dd"}

  
  
したがって、**viewSearch**イベントが**カートイベント**に実装された場合、イベントは次のようになります。

<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: "ハッシュ化されたメールアドレス", hash\_method: "sha256" },

 { event: "viewSearch", checkin\_date: "2016-08-12", checkout\_date: "2016-08-18"},

 { event: "viewBasket", item: \[ { id: "FLIGHT\_ID1", price: 299.99, quantity: 1 }

 \]});

 </script>

This path ends here.

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

## 検索一覧ページのCriteo Tagの3つ以下の商品ID

検索一覧ページには、**カテゴリページ**や**検索結果ページ**などで**複数の商品**が表示されます。これらのページにCriteo Tagを実装すると、Criteoは特定の種類の商品（特定のカテゴリの商品など）に対するユーザーの興味・関心をトラッキングできます。

  
検索一覧ページのCriteo Tag内で上位**3つ**の商品IDを渡すことを強くお勧めします。または、ページに表示される商品の3つの商品IDを渡すことができます。

3つより多い商品IDが渡さた場合

  
3つより多いの商品IDが渡された場合、Criteoは最初に提供された3つのIDのみを考慮します。最大のパフォーマンスを得るには、3つのIDのみを渡すことをお勧めします。

渡された商品IDが3つ未満の場合

  
渡されたIDが3つ未満の場合、Criteoはユーザーの意図を正しく分析できません。これはキャンペーンのパフォーマンスに悪影響を及ぼします。したがって、常に3つのIDをCriteo Tagに渡す必要があります。

このルールの唯一の例外は、検索結果が3つ未満の商品を返す場合のみです。

This path ends here.

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

## netID統合の設定 欧州netID財団

_「_欧州netID財団（European netID Foundation）は、Mediengruppe RTL Deutschland、ProSiebenSat.1、United Internet AGによって、2018年3月に設立されました。__

__同財団は、**米国のシングルサインオンのプロバイダーに代わる欧州における選択肢として、netIDの確立を****目標に掲げています**。netIDのプライバシーセンターを通じて、ユーザーはデータ保護規制に準拠し、かつ透明性を確保しながらインターネットサービスへの同意を整理・管理することができます。__

__これに向けて、同財団はあらゆる業界のユーザーが同じログインデータを使用し、同財団のパートナーのインターネットサービスにアクセスできるようにするオープンスタンダードを開発しました」__  
  
  
 

netID

_「_ユーザーは中心となるnetIDアカウントから、多くのインターネットサービスに簡単にアクセスすることができます。_  
_ログインとパスワード、およびデータ使用の同意には透明性が確保され、プライバシーセンターで整理されます。そして、ユーザーは自身のデータを完全に、かつ排他的に管理することができます。_  
_また、ユーザーはいつでもプライバシーセンターで同意を変更することもできます。_  
_これにより、netIDは高いセキュリティ基準と最大限のデータ主権を保証しています_」_

netIDの公式サイトは、[こちら](https://enid.foundation/en/netid/)をご確認ください。  
  
  
 

netIDとCriteo Tagの統合

##で囲まれたフィールドを動的に置換します。各フィールドの詳細については、以下の表を参照してください。  
  

<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イベント

このイベントは、イベントキューの他のイベントと同様に発火します。

This path ends here.

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

## SHA256 および MD5 (推奨)

Criteo は ID グラフを MD5/SHA256MD5 経由のメールのハッシュから SHA256 に移行しています。データと ID グラフの一致率を最大化するために、特に移行期間中は、新しい SHA256 形式とともにレガシー形式 (MD5 または SHA256MD5) を共有してください。

**setEmail**イベントで送信された MD5 メールと一緒に SHA256 ハッシュされたメールの例を次に示します。

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

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

> **Tip:** ハッシュ化する前に、すべてのユーザーのメール アドレスは次のようにする必要があります。
>
> -   トリミング;ユーザーの電子メール アドレスの前後のすべてのスペースを削除します。
>     
> -   小文字に変換されます。
>     
> -   UTF-8 でエンコードされます。

**setEmail**イベントは、Web サイトにあるすべての Criteo イベント タグ (例: Homepage、Product、AddToCart、Basket、Sales/Conversion) に追加する必要があります。これにより、Web サイトで使用可能な場合はいつでもメールが渡されます。

以下の手順は、MD5 と SHA256 の組み合わせ、または SHA256MD5 と SHA256 の組み合わせを使用して、Criteo のホームページ タグでこのイベントがどのように表示されるかの例です。

- If "MD5 と並んで SHA256": [Example](#step-1950389)
- If "SHA256MD5 と並んで SHA256": [Example](#step-1950652)

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

## SHA256 ハッシュ

SHA256 ハッシュ化されたメールを渡す場合は、 **setEmail**イベントを使用してください。

**setEmail**イベントで送信される SHA256 ハッシュ化メールの例を次に示します。

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

> **Tip:** ハッシュ化する前に、すべてのユーザーのメール アドレスは次のようにする必要があります。
>
> -   トリミング;ユーザーの電子メール アドレスの前後のすべてのスペースを削除します。
>     
> -   小文字に変換されます。
>     
> -   UTF-8 でエンコードされます。

**setEmail**イベントは、Web サイトにあるすべての Criteo イベント タグ (例: Homepage、Product、AddToCart、Basket、Sales/Conversion) に追加する必要があります。これにより、Web サイトで使用可能な場合はいつでもメールが渡されます。

以下のステップに示すのは、このイベントが Criteo のホームページ タグでどのように表示されるかの例です。

Next: [Example](#step-1950477)

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

## 平文

```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 -->
```

プレーン テキストのメールを渡す場合は、 **setEmail**イベントを使用してください。

通常の電子メール アドレスが送信された場合、Criteo はユーザーの電子メール アドレスをデータベースに保存する前に自動的に暗号化します。以下は、 **setEmail**イベントで送信されるプレーンテキスト メールの例です。

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

  
ハッシュ化されていないメール アドレスまたはハッシュ化されたメール アドレスを渡すことができない場合は、空の文字列を送信してください。

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

> **Warning:** 一部の国では、データが保存前にハッシュ化されているかどうかに関係なく、現地の法律により、クリア テキストの電子メール アドレスを第三者に渡すことが許可されていません。 Criteo では、ユーザー情報を共有する前に常にハッシュ化することを推奨していますが、平文のメールを共有することもオプションです。ただし、ハッシュ化されていない情報を共有することを決定した場合に備えて、有効な法律を認識し、ビジネスと市場に最適なアプローチを決定するのはクライアント次第です。

> **Tip:** プレーン テキストを渡す場合、すべてのユーザーのメール アドレスは次のようにする必要があります。
>
> -   トリミング;ユーザーの電子メール アドレスの前後のすべてのスペースを削除します。
>     
> -   小文字に変換されます。
>     
> -   UTF-8 でエンコードされます。

**setEmail**イベントは、Web サイトにあるすべての Criteo イベント タグ (例: Homepage、Product、AddToCart、Basket、Sales/Conversion) に追加する必要があります。これにより、Web サイトで使用可能な場合はいつでもメールが渡されます。

以下は、Criteo のホームページ タグで SHA256 ハッシュを使用してこのイベントがどのように表示されるかの例です。

This path ends here.

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

## MD5 または SHA256MD5 (レガシー)

MD5 または SHA256MD5 ハッシュ化された電子メールを渡す場合は、 **setEmail**イベントを使用してください。

**setEmail**イベントで送信される MD5 ハッシュ化メールの例を次に示します。

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

**setEmail**イベントで送信される SHA256MD5 の例を次に示します。

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

> **Tip:** ハッシュ化する前に、すべてのユーザーのメール アドレスは次のようにする必要があります。
>
> -   トリミング;ユーザーの電子メール アドレスの前後のすべてのスペースを削除します。
>     
> -   小文字に変換されます。
>     
> -   UTF-8 でエンコードされます。

**setEmail**イベントは、Web サイトにあるすべての Criteo イベント タグ (例: Homepage、Product、AddToCart、Basket、Sales/Conversion) に追加する必要があります。これにより、Web サイトで使用可能な場合はいつでもメールが渡されます。

以下のステップは、このイベントが Criteo のホームページ タグでどのように表示されるかの例を示しています。

- If "MD5 ハッシュ": [Example](#step-1958150)
- If "SHA256MD5 ハッシュ": [Example](#step-1958151)

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

## ハッシュ関数

ユーザーの電子メール アドレスを Criteo に渡す前にハッシュ化する場合は、次の関数のいずれかを使用して適切な暗号化を確保できます。

- If "JavaScript を使用した SHA256 ハッシュ関数": [SHA256 Hashing Function using JavaScript](#step-1957333)
- If "C\# を使用した SHA256 ハッシュ関数": [SHA256 Hashing function using C\#](#step-1951709)
- If "Javaを使用したSHA256ハッシュ関数": [SHA256 Hashing function using Java](#step-1951710)
- If "Perlを使ったSHA256ハッシュ関数": [Perlを使ったSHA256ハッシュ関数](#step-1951708)
- If "PHPを使用したSHA256ハッシュ関数": [PHPを使用したSHA256ハッシュ関数](#step-1951742)
- If "PHPを利用したMD5ハッシュ関数": [PHPによるMD5ハッシュ関数](#step-1951849)
- If "C\# を使用した MD5 ハッシュ関数": [C\# を使用した MD5 ハッシュ関数](#step-1951850)
- If "JavaによるMD5ハッシュ関数": [JavaによるMD5ハッシュ関数](#step-1951851)
- If "MD5 hashing function using JS": [MD5 hashing function using JS](#step-3858724)

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

## よくある質問

**ウェブサイトのプライバシー ポリシーを更新する必要がありますか?**

ウェブサイトのプライバシー ポリシーで、電子メール アドレスが収集され、キャンペーンのパフォーマンスを最適化するために協力するサード パーティと共有される可能性があること、およびこの情報が最新かつ最も安全な SHA256 ハッシュ テクノロジを使用してハッシュされることを、ウェブサイトの訪問者に明確に通知する必要があります。そのため、PII データが第三者と共有されることはありません。

さらに、プライバシーを尊重することを訪問者に通知する必要があります。訪問者がそのような情報を共有したくない場合は、Web サイトのユーザー Cookie コンプライアンス バナー (CMP) で希望するオプションを選択することで共有できます。

詳細については、 [Criteo のプライバシー ポリシー](https://help.criteo.com/kb/guide/en/the-criteo-privacy-promise-pDIW4yiawH/Steps/775742)を参照してください。ウェブサイトのプライバシー ポリシー セクションに提供されたリンクを含めることもできます。

> **Tip:** 法務チームがプライバシーに関する懸念を持っている場合、Criteo のビジネス担当者に連絡し、必要に応じて Criteo の法務チームにつなげることができます。

**タグで MD5 形式でハッシュ化された電子メールを既に渡しています。どうすればよいですか?**

この方法を続けて、「hash-method」パラメータが「md5」に設定されていることを確認してください。 Criteo はこの文字列を取得し、保存する前に SHA256 を介してさらにエンコードすることに注意してください。

次に、すべての Criteo タグに「 **setEmail** 」イベントを追加して、SHA256 も渡す必要があります。この追加のイベントが追加されたら、「hashed\_method」パラメータが「sha256」に設定されていることを確認してください。例:

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

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

**タグで SHA256MD5 形式でハッシュ化された電子メールを既に渡しています。どうすればよいですか?**

この方法を続けて、「hash-method」パラメータが「md5」に設定されていることを確認してください。 Criteo はこの文字列を取得し、保存する前に SHA256 ハッシュ エンコードを追加することに注意してください。

次に、すべての Criteo タグに「 **setEmail** 」イベントを追加して、SHA256 も渡す必要があります。この追加のイベントが追加されたら、「hashed\_method」パラメータが「sha256」に設定されていることを確認してください。例:

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

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

**SHA256 でハッシュ化されたメールを渡すことしかできません。どうすればよいですか?**

変更の必要はありません。 「hash\_method」パラメータが「sha256」に設定されていることを確認してください。例:

`{ 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>

## Perlを使ったSHA256ハッシュ関数

```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>

## PHPを使用したSHA256ハッシュ関数

```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>

## PHPによるMD5ハッシュ関数

```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>

## C\# を使用した MD5 ハッシュ関数

```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>

## JavaによるMD5ハッシュ関数

```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.
