Documentation
Feedback
Guides
API Reference

Guides
CheckoutCart AttachmentsAdding marketing information to the cart
Adding marketing information to the cart

The shopping cart gathers information on the products the customer chooses while browsing a store, such as prices, shipping costs, payment methods, delivery methods, etc. This data may include item prices, shipping value, payment, and delivery methods, among others.

This guide will describe how to add marketing data information to the shopping cart via API. For more information about UTMs, read What are utm_source, utm_campaign, and utm_medium.

Getting shopping cart information

The first step is to get the orderFormId of the shopping cart to which you want to add the marketing information. For more information, read the Getting cart information by ID guide.

Adding marketing information to the shopping cart

To add marketing information to the shopping cart, you need to use the Add marketing data endpoint. In this request, you must send the orderFormId through the URL address, as shown in the example below:

https://{accountName}.{environment.com.br}/api/checkout/pub/orderForm/ede846222cd44046ba6c638442c3505a/attachments/marketingData

Additionally, you must send the request body containing the following marketing information:

  • coupon: Coupon code to apply to the cart. Use the cart simulation request to check which coupons can be applied before placing the order.
  • marketingTags: Marketing tags.
  • utmSource: Traffic source (e.g. Facebook, Google).
  • utmMedium: Advertising or marketing media (e.g. banner, CPC).
  • utmCampaign: Campaign name (e.g. Christmas, launch, promo01).
  • utmiPage: utmi_page (internal utm).
  • utmiPart: utmi_part (internal utm).
  • utmiCampaign: utmi_campaign (internal utm).

See a request body example below:


_13
{
_13
"coupon": "free-shipping",
_13
"marketingTags": [
_13
"tag1",
_13
"tag2"
_13
],
_13
"utmSource": "Facebook",
_13
"utmMedium": "CPC",
_13
"utmCampaign": "Black Friday",
_13
"utmiPage": "utmi_page-example",
_13
"utmiPart": "utmi_part-example",
_13
"utmiCampaign": "utmi_campaign-example"
_13
}

After sending the request, the endpoint will return the response body containing the client preferences information in the shopping cart, as in the example below:


_15
...
_15
"marketingData": {
_15
"utmSource": "Facebook",
_15
"utmMedium": "CPC",
_15
"utmCampaign": "Black Friday",
_15
"utmipage": "utmi_page-example",
_15
"utmiPart": "utmi_part-exmaple",
_15
"utmiCampaign": "utmi_campaign-example",
_15
"coupon": "free-shipping",
_15
"marketingTags": [
_15
"tag1",
_15
"tag2"
_15
]
_15
}
_15
...

️ For more information on the meaning of each field available in the shopping cart, see the orderForm overview.

Error codes

The following errors may appear as a message in the response body.

200 - OK

Despite the code 200, which indicates the success of the request, if the coupon code sent is incorrect or unavailable, the following message will appear:


_10
...
_10
"messages": [
_10
{
_10
"code": "couponNotFound",
_10
"text": "Coupon 34324 invalid",
_10
"status": "warning",
_10
"fields": {}
_10
}
_10
]
_10
...

400 - Bad Request

  • Message error example (code ORD002): "Invalid order form". The orderFormId information is not valid.

_10
{
_10
"fields": {},
_10
"error": {
_10
"code": "ORD002",
_10
"message": "Invalid order form",
_10
"exception": null
_10
},
_10
"operationId": "5d9f54e6-7db4-46d6-bca9-deeb278b8b98"
_10
}

404 - Not Found

  • Message error example: "The requested URL was not found on the server": Check if the URL is correct.

_10
<body>
_10
<h1>404 Not Found</h1>
_10
<p>The requested URL was not found on this server.</p>
_10
</body>

Contributors
1
Photo of the contributor
+ 1 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
+ 1 contributors
On this page