Include the following DIVVIT Javascript snippet on each page right underneath the opening  tag (required):

<script type="text/javascript">
!function(){var t=window.divvit=window.divvit||[];if(t.DV_VERSION="1.0.0",t.init=function(e){if(!t.bInitialized){var i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("async",!0),i.setAttribute("src","https://tag.divvit.com/tag.js?id="+e);var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(i,n)}},!t.bInitialized){t.functions=["customer","pageview","cartAdd","cartRemove","cartUpdated","orderPlaced","nlSubscribed","dv"];for(var e=0;e<t.functions.length;e++){var i=t.functions[e];t[i]=function(e){return function(){return Array.prototype.unshift.call(arguments,e),t.push(arguments),t}}(i)}}}();
divvit.init("YOUR_FRONTEND_ID");
divvit.pageview();
</script>

Transmit additional visitor information (optional)

In case the visitor is logged into his or her account, you can transmit this information in a separate function call to Divvit to enhance cross-device tracking abilities.

<script type="text/javascript">
[... see above ...]
divvit.init("YOUR_FRONTEND_ID");
divvit.pageview();
divvit.customer({
   // all these fields will be used to identify this logged-in user
   // you can specify as many fields as you need to uniquely identify a user
   // typically, the email address or customer ID should be enough
   email: "david@smith.com",
   customerId: "123456"
   // ...
});
</script>

Include individual Javascript calls on different page types

Required: Send information about placed orders.

The following code should be placed on the page which the customer reaches after an order has been placed successfully ("thank you" page, or checkout success page).

<script type="text/javascript">
[ ... see above ... ]
divvit.init('YOUR_FRONTEND_ID');
divvit.pageview();
divvit.orderPlaced({
   order: {
      /* products that have been ordered */
      products: [
         {
            /* ID of this product in your shop system */
            id: "13151",
            /* name of the product */
            name: "Some cool product",
            /* category tree for this product */
            category: ['Women', 'Shoes', 'Boots'],
            /*
               price incl. VAT, without shipping (product only)
               no currency symbol, American number formatting
            */
            price: "19.99",
            /*
               [Optional] three letter currency code according to ISO 4217.
               If currency code is not submitted here, a standard currency
               code for this merchant site will be applied automatically.
            */
            currency: "USD",
            /*
               [Optional] quantity if this product has been ordered more than once
               alternatively you can also list the same product twice instead of setting
               quantity to 2
             */
            quantity: "2"
         },
         {
            /* see above */
            id: "15512",
            name: "Another cool product",
            category: ['Men', 'Shirts', 'Dress shirts'],
            price: "29.99",
            currency: "USD"
         }
      ],
      /*
         [Required]
         The identifier you use to identify this order in your shop system
      */
      orderId: "abc1234",
      /*
         [Required]
         Total gross amount incl. shipping cost, payments fees, VAT, and after vouchers have been applied.
         No currency symbol, American number formatting.
      */
      total: "99.99",
      /*
         [Optional]
         Total amount of order before shipping, payment fees, voucher and VAT have been applied.
         In other words, the sum of all product prices net of VAT.
      */
      totalProductsNet: "77",
      /*
         [Optional]
         Three letter currency code according to ISO 4217.
         If currency code is not submitted here, a standard currency
         code for this merchant site will be applied automatically.
      */
      currency: "USD",
      /* [Optional] Shipping charges incurred for this order, including VAT */
      shipping: "6.99",
      /* [Optional] Voucher code, absolute voucher value and voucher type for this order. Can be omitted in case no voucher was used. */
      voucher: "PROMO-50",
      voucherDiscount: "9.99", // including VAT
      /* Voucher types: promo (promotional voucher), sorry (apology for problem in the past), refund (refund of previous order). */
      voucherType: "promo",
      // If multiple vouchers are allowed in your shop, you can also pass them as an array:
      vouchers: [
         {
            voucher: "PROMO-10",
            voucherDiscount: "19.99"
         },
         {
         // ...
         }
      ]
      /* [Optional] If a payment fee has been applied for this order, please specify it here. Can be omitted when not applicable.  */
      paymentFee: "4.99",
      /* [Optional] Can be one of the following: paypal, credit-card, direct-debit, invoice, cash-on-delivery, other.  */
      paymentMethod: "credit-card",
      /*
         [Optional]
         Information about the customer who placed this order. This is required to identify follow-up orders of the same customer.
         You can specify one more more ID fields that uniquely identify this customer.
      */
      customer: {
         idFields: {
            email: "david@smith.com"
         },
         name: "David Smith"
      }
   }
});
</script>

Optional: Update products in cart

To track products that have been added to the cart, you can either go for an event-based approach or update the total cart each time the user adds or removes a product.

<script type="text/javascript">
// event-based:
divvit.cartAdd({
   /* [Optional] Identifier to identify this cart. If not provided,
      the a cookie will be used to identify the customer's cart.
   */
   cartId: "123abc",
   product: {
      id: "123411",
      name: "Black shoe suede",
      category: ['Women', 'Shoes', 'Boots'],
      price: "122.99",
      currency: "USD",
      quantity: "2"
   }
});
[...]
divvit.cartRemove({
   /* [Optional] Identifier to identify this cart */
   cartId: "123abc",
   product: {
      id: "123411"
   }
});
// OR update totals:
divvit.cartUpdated({
   /* [Optional] Identifier to identify this cart. If not provided,
      the a cookie will be used to identify the customer's cart.
   */
   cartId: "123abc",
   products: [
      {
         id: "13151",
         name: "Some cool product",
         category: ['Women', 'Shoes', 'Boots'],
         price: "19.99"
      },
      {
         id: "15512",
         name: "Another cool product",
         category: ['Men', 'Shirts', 'Dress shirts'],
         price: "29.99",
         quantity: "2"
      }
   ],
   /* [Optional] Voucher code, absolute voucher value and voucher type for this order. Can be omitted in case no voucher was used. */
   voucher: "PROMO-50",
   voucherDiscount: "9.99",
   /* Voucher types: promo (promotional voucher), sorry (apology for problem in the past), refund (refund of previous order). */
   voucherType: "promo",
   // OR multiple vouchers:
   vouchers: [
      {
         voucher: "VOUCHER_CODE1",
         voucherDiscount: "9.99"
      },
      {
         // ...
      }
   ]
});
</script>
Did this answer your question?