Smar Documentation: Difference between revisions

From Barion Documentation
Jump to navigation Jump to search
(Created page with "{{PageTitle|title=Documentation of smar.js}}")
 
No edit summary
Line 1: Line 1:
{{PageTitle|title=Documentation of smar.js}}
{{PageTitle|title=Documentation of smar.js}}
{{PageTitle|title=Documentation of smar.js}}
{| style="margin-left:2em;" align="right"
| __TOC__
|}
== Prerequisites ==
The current version of smar.js does not send initiateCheckout and initiatePurchase event. All pages (including the order summary) need to include the following libraries:
• jQuery 1.1+
• bp.js
== Installation ==
Paste the following snippet before the closing body tag:
Write the selectors for the buttons to the attributes respectively.
- _grantconsent_: The selector of the element on which the user clicks a grantconsent event should be sent
- _rejectconsent_: The selector of the element on which the user clicks a rejectconsent event should be sent
- _add2cart_: The selector of the element on which the user clicks an addtocart event should be sent. This attribute is optional
As the smar.js library relies on jQuery, all the selector or selectors can be used here. More information on selectors can be found here: https://api.jquery.com/category/selectors/
=== Examples ===
Here is an example of the embedding code:
The selectors can be checked with the help of Google Chrome console (Ctrl + Shift + I on Windows), then click on the arrow icon in the top left corner, then click on the button as shown on the screenshot below. In the selected line, copy a unique label from the class attribute of the button tag to the appropriate attribute of the embedding script tag.
The grantconsent event listener is attached to a button with cc-allow class:
The addtocart event listener is attached to any element with add-to-cart class and a button with add-to-cart id.
{| class="wikitable"
! Event
! Description
! Needed identifiers
|-
! Event
| grantConsent
|-
! Description
| Customer grants access to storing marketing cookies
|-
! Needed Identifiers
| Fill the _grantconsent_ attribute with the appropriate selector
|
| A _grantconsent_ is also sent, when the user clicks on a button with _.cc-btn-accept-all_ class
|
| A _grantconsent_ is also sent, if the checkbox with _#marketing-cookies-checkbox_ is checked
|}

Revision as of 14:00, 7 September 2021

Documentation of smar.js

Documentation of smar.js

Prerequisites

The current version of smar.js does not send initiateCheckout and initiatePurchase event. All pages (including the order summary) need to include the following libraries: • jQuery 1.1+ • bp.js

Installation

Paste the following snippet before the closing body tag:

Write the selectors for the buttons to the attributes respectively. - _grantconsent_: The selector of the element on which the user clicks a grantconsent event should be sent - _rejectconsent_: The selector of the element on which the user clicks a rejectconsent event should be sent - _add2cart_: The selector of the element on which the user clicks an addtocart event should be sent. This attribute is optional As the smar.js library relies on jQuery, all the selector or selectors can be used here. More information on selectors can be found here: https://api.jquery.com/category/selectors/

Examples

Here is an example of the embedding code:

The selectors can be checked with the help of Google Chrome console (Ctrl + Shift + I on Windows), then click on the arrow icon in the top left corner, then click on the button as shown on the screenshot below. In the selected line, copy a unique label from the class attribute of the button tag to the appropriate attribute of the embedding script tag.

The grantconsent event listener is attached to a button with cc-allow class:

The addtocart event listener is attached to any element with add-to-cart class and a button with add-to-cart id.

Event Description Needed identifiers
Event grantConsent
Description Customer grants access to storing marketing cookies
Needed Identifiers Fill the _grantconsent_ attribute with the appropriate selector A _grantconsent_ is also sent, when the user clicks on a button with _.cc-btn-accept-all_ class A _grantconsent_ is also sent, if the checkbox with _#marketing-cookies-checkbox_ is checked