E-commerce

Web client integration can be done via GTM Tag or by adding inline JavaScript.

API Base URL

Testing:

https://winfluenced-pixel-rvlaoxgvjq-ey.a.run.app

Test Api Swagger Url:

https://winfluenced-pixel-rvlaoxgvjq-ey.a.run.app/swagger/index.html

Sample Client script

<script>
  var transactionData = {
    customer_no: {{User - Customer ID}},
    order_no: {{Ecommerce - UA - Transaction - ID}},
    basket_items: {{Ecommerce - All}},
    order_tax: Math.floor({{cd_order_tax}}).toFixed(2),
    order_shipping: Math.floor({{Ecommerce - Purchase - Shipping}}).toFixed(2),
    order_total_discount: null,
    order_total: Math.floor({{Ecommerce - Purchase - Revenue}}).toFixed(2),
    voucher_code: {{Ecommerce - Purchase - Coupon Code}},
    user_type: '',
    sales_channel: ''
};

(function sendConversion() {
    function getAdpCookieValue(cookieName, i) {
        var cookieValue = document.cookie.match(new RegExp('(^| )' + cookieName + '=([^;]+)'));
        var values = (cookieValue ? cookieValue.pop() : '').split('_');
        return (values.length >= i) ? values[i] : '';
    }

    var conversion_data = {
        "transactionId": getAdpCookieValue("_adp", 0), // ClickID reads from _adp cookie
        "offerId": getAdpCookieValue("_adp", 1),  // OfferID reads from _adp cookie
        "advertiserId": "{Advertiser ID}", // Replace with the brand Advertiser ID provided by Adpartners
        "goalName": null, // Optional 
        "buyerId": transactionData.customer_no,
        "orderNo": transactionData.order_no,
        "basketItems": [],
        "totalDiscount": transactionData.order_total_discount,
        "totalShippingAmount": transactionData.order_shipping,
        "totalTax": transactionData.order_tax,
        "totalAmount": transactionData.order_total,
        "voucherCode": transactionData.voucher_code,
        "userType": transactionData.userType,
        "salesChannel": transactionData.salesChannel
    }
    for (i = 0; i < transactionData.basket_items.purchase.products.length; i++) {
        conversion_data.basketItems.push({
            "skuId": transactionData.basket_items.purchase.products[i].id,
            "sellerId": transactionData.basket_items.purchase.products[i].dimension98,
            "productType": '',
            "productName": transactionData.basket_items.purchase.products[i].name,
            "categoryName": transactionData.basket_items.purchase.products[i].category,
            "quantity": parseInt(transactionData.basket_items.purchase.products[i].quantity),
            "brandName": transactionData.basket_items.purchase.products[i].brand,
            "discountedAmount": {{2- cJS - Product price Array - Purchase - GelirOrtakları}},
            "unitePrice": null,
            "uniteDiscount": null
        });
    }
    if(conversion_data.transactionId && conversion_data.transactionId != '')
    {
      fetch('{API Base URL}/api/pixel/ecomm', {
        method: "POST",
        body: JSON.stringify(conversion_data),
        headers: {
            "Content-Type": "application/json"
        },
      });
    }
})();
</script>

Conversion Endpoint: Conversion pixel will send a post request with conversion data the following API method. You may find the schema and field properties bellow.

Create Conversion API Action

// sample request

{
    "transactionId": "1027a7ebbda461fce952fd2f964",
    "offerId": "18",
    "advertiserId": "{Advertiser ID}",
    "goalName": null,
    "buyerId": "23086",
    "orderNo": "2443837024301",
    "basketItems": [
        {
            "skuId": "8680044381895",
            "sellerId": "",
            "productType": "SEZONSUZ",
            "productName": "Paris Magnet",
            "categoryName": "Kasa Önü",
            "quantity": 1,
            "brandName": "%50+%20 OUTLET PROMOSYONU",
            "discountedAmount": 57.99,
            "unitePrice": null,
            "uniteDiscount": 0
        }
    ],
    "totalDiscount": 40.59,
    "totalShippingAmount": 44.90,
    "totalTax": null,
    "totalAmount": 62.30,
    "voucherCode": "undefined",
    "userType": "Return",
    "salesChannel": "Web"
}

Conversion tracking for e-commerce order transactions.

post
Body
transactionIdstring | nullableOptional

Click - Transaction Id

advertiserIdstring | nullableOptional

Advertiser Adpartners ID

buyerIdstring | nullableOptional

Customer number

offerIdstring | nullableOptional

Offer id, (Optional)

goalNamestring | nullableOptional

Category base, commission goal name, (Optional)

orderNostring | nullableOptional

Conversion no, Order no

totalDiscountnumber · float | nullableOptional

Order total discount

totalShippingAmountnumber · float | nullableOptional

Order total shipping amount

totalTaxnumber · float | nullableOptional

Order total tax

totalAmountnumber · float | nullableOptional

Order total amount, (include tax shipping and discounts) Final revenue

voucherCodestring | nullableOptional

Order coupon code

userTypestring | nullableOptional

New or existing user

salesChannelstring | nullableOptional

Sales channel; web, ios and android

Responses
200

Success

No content

post
POST /api/pixel/ecomm HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 448

{
  "transactionId": "text",
  "advertiserId": "text",
  "buyerId": "text",
  "offerId": "text",
  "goalName": "text",
  "orderNo": "text",
  "basketItems": [
    {
      "skuId": "text",
      "sellerId": "text",
      "productType": "text",
      "productName": "text",
      "categoryName": "text",
      "quantity": 1,
      "brandName": "text",
      "discountedAmount": 1,
      "unitePrice": 1,
      "uniteDiscount": 1
    }
  ],
  "totalDiscount": 1,
  "totalShippingAmount": 1,
  "totalTax": 1,
  "totalAmount": 1,
  "voucherCode": "text",
  "userType": "text",
  "salesChannel": "text"
}
200

Success

No content

Last updated