Notifier l'événement d'achat effectué

The event “Notify purchase completed event” is used to describe a purchase made by the customer. It notifies, via JavaScript, when a user completes a purchase using the connectif.managed.sendEvents.

  

This article is part of the guide to creating a custom integration.
If your integration is through a module, this notification will be inserted into your eCommerce automatically.

 

How to use it

The shopping cart notification uses the entityInfo option of the sendEvents method to enrich the information of the events sent.

  

This event serves as an alternative to implementing the "Purchase completed" tag in the HTML of your store or website.

 

Notify the completed purchase

This object represents the Shopping Cart model which includes the following properties: 

Name Required Type Description
purchaseId Yes string Unique identifier of the purchase.
cartId No string Unique identifier of the cart from which this purchase originated.
totalQuantity Yes number Total number of products in the purchase (including duplicates).
For example: if a cart has 3 units of one product and 7 units of another, totalQuantity will be 10.
totalPrice Yes number Total purchase amount.
purchaseDate No string Date of the purchase. Expected ISO_8601 format.
paymentMethod No string The payment method
products Yes Product Basket Item Items included in the purchase, along with their quantity and total price.
 

Although optional, the cartId field is highly recommended to mark the cart as purchased and prevent incorrect Abandoned Cart events.

 

Example

The notification will look like this:

connectif.managed.sendEvents([
    {
        "type": "purchase",
        "purchase": {
            "cartId": "cart-0098caf9-42f4-44e9-afdd-45eafe892293",
            "totalQuantity": 1,
            "totalPrice": 51.88,
            "products": [{
                "name": "My Product",
                "productDetailUrl": "https://myshop.com/product/details/59a31949a1a562d4979fbca2",
                "productId": "59a31949a1a562d4979fbca2",
                "unitPrice": 51.88,
                "availability": "outofstock",
                "imageUrl": "https://myshop.com/img/59a31949a1a562d4979fbca2.jpg",
                "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                "priority": 10,
                "rating": 4,
                "tags": ["tag1", "tag2", "tag3"],
                "relatedExternalProductIds": ["59a31953a1a562d4979fbd90", "59a31b2ba1a562d4979fe5b8"],
                "brand": "Jata",
                "publishedAt": "2020-05-03T10:15:00Z",
                "quantity": 1,
                "price": 51.88
            }],
            "purchaseId": "purchase-e3418b5a-8709-4593-a7c8-d8a7f12df737",
            "purchaseDate": "2020-06-26T12:52:51.591Z",
            "paymentMethod": "Credit Card"
        }
    },
    {
        "type": "page-visit"
    }], { entityInfo });
  

Normally, the purchase registration is notified along with the page visit event. This typically represents the visit to the order confirmation or purchase page.

 

 

Congratulations!
You've reached the end of the lesson.

  

Do you still have any unresolved questions?
Remember that our Connectif specialists are available to help you. To contact them, simply open a support ticket by clicking on the blue “Help” button in your dashboard.


Keep learning!

To make the most of your Connectif account, we recommend continuing with the following articles:

Cet article vous a-t-il été utile ?
Utilisateurs qui ont trouvé cela utile : 0 sur 0