# Reporting Conversions

Cartographer does not force a specific way of adding products to the cart or completing checkout, leaving implementation details to the site integration layer. Thus, to provide accurate analytics and to be able to calculate runtime costs, Cartographer requires implementors to submit "add to cart" and "checkout complete" events.

TIP

In some circumstances, Drive Commerce may provide an option to self-host required external scripts. Please contact Support for additional details.

# Add to Cart

Add to cart event shall be submitted whenever a customer selects a specific product and adds it to cart. Submitted data should be a semi-color separated list of four data elements:

  • Product variant ID, or Product ID for standard products.
  • Parent product ID, or empty for standard products.
  • Product price. Price should reflect all active customer promotions and discounts.
  • Product price currency.

These four data elements should be repeated for all products that are being added to cart.

TIP

It is recommended to submit all add to cart events. Cartographer tracks which products have been recommended to the current user, and will perform necessary filtering on the server side.

# Submit Add to Cart Event

// Multiple products may be submitted at the same time.
var submitData = [{
    productId: someProductId,
    parentProductId: someParentId,
    price: someProductPrice,
    priceCurrency: somePriceCurrency,
    quantity: 1
}];

(function () {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'https://api.cartographer.drivecommerce.com/api/v3/runtime/addtocart?type=production&products=' + JSON.stringify(submitData) + '&time=' + (new Date().getTime());
    document.getElementsByTagName('body')[0].appendChild(script);
})();

# Checkout

Checkout events should be submitted after successfully completing the checkout. Please see Add to Cart section about required product data format.

TIP

It is recommended to submit all successful checkout events. Cartographer tracks which products have been recommended to the current user and will perform necessary filtering on the server side.

# Submit Checkout event

// Multiple products may be submitted at the same time.
var submitData = [{
    productId: someProductId,
    parentProductId: someParentId,
    price: someProductPrice,
    priceCurrency: somePriceCurrency,
    quantity: 1
}];

(function () {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'https://api.cartographer.drivecommerce.com/api/v3/runtime/checkout?type=production&products=' + JSON.stringify(submitData) + '&time=' + (new Date().getTime());
    document.getElementsByTagName('body')[0].appendChild(script);
})();