Conversion Tag

Web client conversion tracking integration can be done via Google Tag Manager (GTM) tag or by adding inline JavaScript.

circle-info

Conversion implementation must be placed only the order confirmation or "Tank you" page on your site.

JavaScript Implementation

//Paste this code before the closing </body> tag:
  <script type="module">
    import * as adp from "https://cdn.adpartners.io/adp-client/dist/adp-client-v2.js";
    window._adp = window._adp || adp;
    
    const currencyList =adp.Currency;
    const offerDims=adp.OfferDimension;
    //define adpartners config--> 
    const adpConfig={measurementId: "xxxx-yyyy", advertiserId:"xxxx"};
    //define adpartners config--<
    const adpClient=adp.initEcommClient(adpConfig);
    //check if affiliate is available before futher actions -->
    if(!adpClient.isAffiliateAvailable()){
      //if there is no affiliate cancel execution and return
      console?.log("adp affiliate is not available");
    } 
    //check if affiliate is available before futher actions --<
    else {
    //initialize purchase order -->
    const order=adp.initPurchaseOrder(adpConfig);
    order.customerId= "uniq customer id"; //required
    order.orderNumber= "purchase order number of the customer"; //required
    order.totalAmount=1000.00; //required
    order.currencyCode= currencyList.TRY.Code; //(default TRY) 3 digit currecy code https://en.wikipedia.org/wiki/ISO_4217    
    //initialize purchase order --<
    
    //initialize purchase order line item -->
    const item1= new adp.PurchaseOrderLineItem();
    item1.brandId="uniq brand id" //optional if affliate is not based on brandId
    item1.brandName="uniq brand name" //optional if affliate is not based on brandName
    item1.categoryId="uniq category id" //optional if affliate is not based on categoryId
    item1.categoryName="uniq category name" //optional if affliate is not based on categoryName
    item1.cateogryList= ["uniq category name1","uniq category name2"] //optional if affliate is not based on categoryList
    item1.id="line item id or basket id" //optinal
    item1.sku="sku of the product" //required
    item1.productCode="product code or barchode of the product" //optional
    item1.productName="name of the product"; //required
    item1.sellerId="seller id of the product"; //optional
  
    item1.unitSalePrice=108.00 //optional actual sale price per unit (what customers actually pays)
    item1.quantity=2;
    item1.lineAmount= 216.00; //required (unitSalePrice * quantity)
    item1.offerDimension=offerDims.categoryName; //(default categoryName) required if commission dimension is different
    order.items.push(item1);
    //initialize purchase order line item --<
    
    /** there can be more line items, 
    * those items will be generated the same way as item1 created
    */
    //initialize purchase order line item -->
    const item2= new adp.PurchaseOrderLineItem();
    item2.brandId="uniq brand id" //optional if affliate is not based on brandId
    item2.brandName="uniq brand name" //optional if affliate is not based on brandName
    item2.categoryId="uniq category id" //optional if affliate is not based on categoryId
    item2.categoryName="uniq category name" //optional if affliate is not based on categoryName
    item2.cateogryList= ["uniq category name1","uniq category name2"] //optional if affliate is not based on categoryList
    item2.id="line item id or basket id" //optinal
    item2.sku="sku of the product" //required
    item2.productCode="product code or barchode of the product" //optional
    item2.productName="name of the product"; //required
    item2.sellerId="seller id of the product"; //optional
  
    item2.unitSalePrice=108.00 //optional actual sale price per unit (what customers actually pays)
    item2.quantity=2;
    item2.lineAmount= 216.00; //required (unitSalePrice * quantity)
    item2.offerDimension=offerDims.categoryName; //(default categoryName) required if commission dimension is different
    order.items.push(item2);
    //initialize purchase order line item --<
    
        
    //validate and and save conversion -->
    adpClient.sendPurchaseOrder(order); //if there are validation erros, they will be shown in browser console
    //validate and and save conversion -->
    }
  </script>

GTM Implementation

For GTM implementation the same Javascript code can be used except GTM variables must placed appropriate position in order to assign proper values to object properties.

Last updated