Add to cart

This event marks adding a product to the shopping cart

💡

Using the Tweakwise JS implementation?

This event is automatically included when you're using a button with the 'twn.add-to-cart' event on the Tweakwise product tiles.

In all other scenarios, you'll have to implement it manually. (i.e. product detail page)

To the API-reference

How to implement?

<!-- INSTANCE_KEY SESSION_KEY AND PROFILE_KEY are inherited from the base tag -->
<script>
  tweakwiseLayer.push({
	  event: 'addtocart',
	  data: {
	  	productKey: 'ARTICLE_NUMBER',
  		quantity: QUANTITY,
  		totalAmount: TOTAL_AMOUNT
  	}
  });
</script>
curl --request POST \
     --url 'https://navigator-analytics.tweakwise.com/api/addtocart?instanceKey=INSTANCE_KEY' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "ProfileKey": "PROFILE_KEY",
  "SessionKey": "SESSION_KEY",
  "ProductKey": "ITEM_ID",
  "Quantity": "QUANTITY",
  "TotalAmount": "TOTAL_AMOUNT"
}
'

Parameters

NameTypeRequiredDescription
INSTANCE_KEYURL-parameter - textyesYour Tweakwise Instance Key
PROFILE_KEYBody parameter - textyesThe ID that identifies the current visitor. Read more about the profile key here
SESSION_KEYBody parameter - textyesThe session key for the specific user. This can be your own session key, GA session. As long as it's consistent over the user's session.
Allowed characters: alphanumeric and hyphens
ITEM_IDBody parameter - textyesThe Tweakwise item ID of the current product
QUANTITYBody parameter - numberyesAmount of items of the product that's added to the cart
TOTAL_AMOUNTBody parameter - decimalyesTotal amount of the products added to the cart

When do I submit this event?

Submit this event when adding a product to the shopping cart

Where do I implement this event in the code?

On every page where you are able to add a product to the shopping cart

How to handle event-specific warnings from Tweakwise

⚠️No AddToCarts received in the last 4 days

Description

No AddToCarts events have been received in the last 4 days.

Possible solution

Check the tracking on all add-to-cart buttons (on product pages as well as quick-add buttons in category views).

⚠️SessionKey: xx% missing / ProfileKey: xx% missing / ProductKey: xx% missing / Quantity: xx% missing / TotalAmount: xx% missing

Description

More than 0.5% of the AddToCarts events are missing the mentioned field.

Possible solution

Inspect the payload sent when adding an item to the cart and make sure quantities, amounts, session IDs, and product IDs are included.

⚠️ProductKey: xx% not found

Description

More than 7% of the AddToCarts events specify a ProductKey that is missing from Tweakwise.

Possible solution

Verify whether item IDs used during add-to-cart interactions match to an actual Item ID in Tweakwise.

⚠️Mismatched sessionkeys in this event and SessionStart (xx%)

Description

More than 5% of the AddToCarts events use a SessionKey that is not associated with a recorded SessionStart.

Possible solution

Review cookie and session handling around shopping cart interactions to guarantee the session key persists correctly.

Please share your findings with your implementation partner. If they have questions about these messages, please have them contact [email protected]