Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var email_md5 = "e13743a7f1db7f4246badd6fd6ff54ff" // input here the email of the client hashed in md5 - if email is not available
- var email_sha256_md5 = "000e3171a5110c35c69d060112bd0ba55d9631c7c2ec93f1840e4570095b263a" // input here the email of the client hashed in md5 than in sha256 - if md5 not availalble
- var accountid = 11532 //input here your account id
- var store_id = 17 // input here the store_id
- var transaction_id = "tr123456" //input here the current transaction Id
- var timestamp = "2017-06-02T12:24:10Z" //input here the timestamp of the time when the conversion happened / ISO 8601
- var currency = "EUR" //input here the currency
- var itemArray = [
- {
- "id" : "2015-02-12_aime la plagne_landry", // Product ID
- "price" : 23, // Price in partner currency
- "quantity" : 1 // Must be an integral number
- },
- {
- "id" : "otherprod5436",
- "price" : 102,
- "quantity" : 3
- }
- ]; // input here the array of product IDs, unit prices and quantity
- //-----------------------------------------------------
- // Do not modify below this point :
- var http = new XMLHttpRequest();
- var endpoint = "https://widget.criteo.com/m/event?apiKey=omnichannel_direct";
- var body = {
- "id" :
- {
- // Email
- "email" :
- {
- "raw" : email
- }
- },
- // IP adress - set it to 127.0.0.1 if not applicable
- "ip" : "127.0.0.1",
- // Partner ID
- "account" : accountid,
- // Outlet type
- "site_type" : "instore",
- // Event array
- "events" : [
- // Sale event
- {
- "event" : "trackTransaction",
- "store_id" : store_id,
- "offline_sale_ingestion" : 1,
- "user_segment" : 17,
- "id" : transaction_id, // Transaction ID
- "timestamp" : timestamp, // UTC timestamp (ISO 8601 with explicit UTC timezone designator 'Z')
- "currency" : currency, // Optional override of the partner's default currency
- // Product array
- "item" : itemArray
- }
- ]
- };
- http.open("POST", endpoint, true);
- //Send the proper header information along with the request
- http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- http.onreadystatechange = function() {//Call a function when the state changes.
- if(http.readyState == 4 && http.status == 200) {
- alert(http.responseText);
- }
- }
- http.send(JSON.stringify(body));
- // if necessary call this function to reformat the Item Array
- function formatProducts(productsArray, nameofProductID = "id", nameofproductPrice = "price", nameofQuantity = "quantity") {
- //declare the table that is going to be use in our tags
- var products = [];
- for (var i = 0; i < productsArray.length; i++) {
- products.push({
- //copy the id from your table, this is just an example :
- id: productsArray[i][nameofProductID],
- //copy the price from your table, this is just an example :
- price: productsArray[i][nameofproductPrice],
- //copy the quantity from your table, this is just an example
- quantity: productsArray[i][nameofQuantity]
- });
- }
- return products;
- }
Advertisement
Add Comment
Please, Sign In to add comment