Skip to main content

Google Analytics intergation

Fire Google Analytics event when user clicks Finish button and adds product to cart in the configurator.

document.addEventListener('mimeeq-add-to-cart', (event) => {
/**
* Remember to create GA event best suiting your use case https://support.google.com/analytics
* This is standard `CustomEvent`,
* to learn more, check: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
* All payload data can be found under `event.detail` property.
* {
* customerId: dataCustomerId,
* action: variant === 'basket' ? 'addToCart' : 'select',
* variantCode: `${prefix}=${configurationCode}`,
* shortCode: configurationShortCode,
* configurationCode,
* productId,
* qty: quantity,
* code: prefix,
* productName,
* collectionId,
* selectedOptions,
* isModular,
* embedShortCode,
* sku,
* }
*
*/
gtag('event', 'Add to Cart', {
event_category: 'cart',
event_label: event.detail,
});
});