@empathyco/x-components 3.1.0-alpha.1 → 3.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -213,6 +213,7 @@ out further information about:
|
|
|
213
213
|
- **Functions supported by the [X API object](#x-api)** to initialize Interface X
|
|
214
214
|
- Notes on how to set up [**the preview of query results**](#dynamic-query-results-preview) for
|
|
215
215
|
determined queries at the pre-search stage
|
|
216
|
+
- [**Tracking options for add to cart events**](#tracking-events-for-add-to-cart-on-product-detail-pages) from product detail pages
|
|
216
217
|
|
|
217
218
|
### Snippet configuration
|
|
218
219
|
|
|
@@ -405,3 +406,64 @@ instance:
|
|
|
405
406
|
});
|
|
406
407
|
</script>
|
|
407
408
|
```
|
|
409
|
+
|
|
410
|
+
### Tracking events for add to cart on product detail pages
|
|
411
|
+
|
|
412
|
+
Empathy Platform Interface X allows you to track shoppers' add-to-cart interactions from any product detail page (PDP) in your commerce store, regardless of whether your commerce store is running on a **single-page application or not**.
|
|
413
|
+
|
|
414
|
+
#### Tracking add-to-cart events on non-SPA webpages
|
|
415
|
+
To track your shoppers' add-to-cart interactions from any PDP based on a non-spa structured webpage, follow these steps:
|
|
416
|
+
|
|
417
|
+
1. Add the `productId` parameter when initializing the script.
|
|
418
|
+
|
|
419
|
+
```html
|
|
420
|
+
window.InterfaceX.init({
|
|
421
|
+
instance: "instanceName",
|
|
422
|
+
lang: "es",
|
|
423
|
+
documentDirection: "ltr",
|
|
424
|
+
scope: 'desktop',
|
|
425
|
+
currency: "EUR",
|
|
426
|
+
consent: true,
|
|
427
|
+
isSPA: false,
|
|
428
|
+
queriesPreview: []
|
|
429
|
+
{
|
|
430
|
+
query: 'coats',
|
|
431
|
+
title: 'Winter Coats'
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
callbacks: {
|
|
435
|
+
UserClickedAResult: function(a, b, e, t) {}
|
|
436
|
+
},
|
|
437
|
+
productId: '11776347-ES' // Add this parameter
|
|
438
|
+
})
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
2. Call the `InterfaceX.addProductToCart('11776347-ES')` function to track the event when the add-to-cart button is clicked.
|
|
442
|
+
|
|
443
|
+
```html
|
|
444
|
+
yourCommerceStoreEnvironment.addToCartButton.addEventListener('click', () =>
|
|
445
|
+
InterfaceX.addProductToCart('11776347-ES');
|
|
446
|
+
);
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
#### Tracking add-to-cart events on SPA webpages
|
|
451
|
+
To track your shoppers' add-to-cart interactions from any PDP based on a SPA structured webpage, follow these steps:
|
|
452
|
+
|
|
453
|
+
1. Call the `InterfaceX.bus.emit('PDPIsLoaded')` function any time a new PDP-type page is loaded.
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
```html
|
|
457
|
+
if (yourCommerceStoreEnvironment.isPDP && window.initX.isSpa) {
|
|
458
|
+
InterfaceX.bus.emit('PDPIsLoaded')
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
2. Call the `InterfaceX.addProductToCart()` function to track the event when the add-to-cart button is clicked:
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
```html
|
|
466
|
+
yourCommerceStoreEnvironment.addToCartButton.addEventListener('click', () =>
|
|
467
|
+
InterfaceX.addProductToCart();
|
|
468
|
+
);
|
|
469
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "3.1.0-alpha.
|
|
3
|
+
"version": "3.1.0-alpha.2",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -143,5 +143,5 @@
|
|
|
143
143
|
"access": "public",
|
|
144
144
|
"directory": "dist"
|
|
145
145
|
},
|
|
146
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "1096966c93eab5719555bb24779d94bf15a70570"
|
|
147
147
|
}
|