Retail Engine, 2026

Wiki source code of Web events and sessions


Hide last authors
Andrej Rylov 1.1 1 (% class="lead" %)
Vera Retyeva 4.1 2 Web events and sessions are used in Smart Communications to process customer actions on an online store website or in a mobile app.
Andrej Rylov 1.1 3
4 (% class="box" %)
5 (((
6 **Contents:**
7
8 {{toc depth="3" start="2"/}}
9 )))
10
11 == **Web events** ==
12
Vera Retyeva 4.1 13 A web event is an action performed by a customer on a website or in a mobile app. In Smart Communications, web events are objects stored in the database that can be used to build segments, as well as in campaigns and bulk messages.
Andrej Rylov 1.1 14
Andrej Rylov 3.1 15 Web events are linked to an [[event source>>doc:Main.Smart_Communications.SMC_Use.Settings_SC.Event_sources.WebHome]] (for example, one of several websites or a mobile app).
Andrej Rylov 1.1 16
Andrej Rylov 3.1 17 Along with information about the web event, its [[context>>doc:Main.Smart_Communications.SMC_Use.Events_SmC.WebHome||anchor="HEventContext"]] may also be saved. Event context is an object associated with the event. For example, along with the **Product added to cart** event, the **Product** object will be saved, i.e., the values of all [[fields>>doc:Main.Smart_Communications.SMC_Use.Settings_SC.Data_field.WebHome]] of the product added to the cart.
Andrej Rylov 1.1 18
19 {{info}}
20 The object stored in the web event context is static—its attributes retain the values they had at the time of the event. For example, if you display a product price from the web event context in a message text, the customer will see the price at the time of the event, not at the time the message is sent.
21
Andrej Rylov 3.1 22 This principle underlies the operation of certain triggers, such as [[Price changed for viewed product>>doc:Main.Smart_Communications.SMC_Use.Campaigns.Triggers.WebHome||anchor="HThepriceoftheviewedproducthaschanged"]].
Andrej Rylov 1.1 23 {{/info}}
24
Andrej Rylov 3.1 25 === **Methods for receiving information about web events** ===
Andrej Rylov 1.1 26
Vera Retyeva 4.1 27 Smart Communications can receive information about web events in three ways, described below. Regardless of the transmission method, Smart Communications creates an object with the same set of attributes ([[fields>>doc:Main.Smart_Communications.SMC_Use.Settings_SC.Data_field.WebHome]]) and available actions.
Andrej Rylov 1.1 28
29 ==== **JS tracker** ====
30
Andrej Rylov 3.1 31 The [[JS tracker>>doc:Main.Smart_Communications.SMC_integration.JS_tracker.WebHome]] includes a set of preconfigured web events (such as website authorization or product view), as well as the ability to configure arbitrary custom events (for example, a customer giving a product a low rating).
Andrej Rylov 1.1 32
33 ==== **Mobile SDK** ====
34
Vera Retyeva 4.1 35 The ##event## method of the [[Mobile SDK>>doc:Main.Smart_Communications.SMC_integration.MobileSDK.WebHome||anchor="event"]] allows transmitting arbitrary web events related to customer activity in the mobile app to Smart Communications. The set of supported events is configured during integration.
Andrej Rylov 1.1 36
37 ==== **REST API** ====
38
Vera Retyeva 4.1 39 The Partner's master system can transmit information about web events to Smart Communications via [[REST API>>doc:Main.Smart_Communications.SMC_integration.Data_exchange.SmC_API.WebHome]] calls ([[Web_event>>doc:Main.Smart_Communications.SMC_integration.Data_exchange.SmC_API.SmC_API_methods.Web_event.WebHome]] method).
Andrej Rylov 1.1 40
41 == **Sessions** ==
42
Andrej Rylov 3.1 43 A session is a sequence of customer actions on a website or in a mobile app (i.e., a sequence of web events). The session identifier is a mandatory attribute of a web event and allows linking it to the customer.
Andrej Rylov 1.1 44
Andrej Rylov 3.1 45 {{warning}}
46 Within each session, the **Customer authorization** (##user_login##) or **Website visit** (##user_visit##) event must be transmitted with the session identifier (##session_id##) and customer identifier in the master system (##user_id##) fields filled in.
Andrej Rylov 1.1 47
Andrej Rylov 3.1 48 For all other events, transmitting the customer identifier is not required. Events are linked to the customer via the session identifier.
49 {{/warning}}
Andrej Rylov 1.1 50
Vera Retyeva 4.1 51 If no ##user_login## or ##user_visit## event with a filled customer identifier field was transmitted within the session (for example, a customer browses products on the site without logging in), the session will be anonymous. Anonymous sessions are stored in the Smart Communications database for 60 days.
Andrej Rylov 1.1 52
Vera Retyeva 4.1 53 Session handling logic differs depending on how web events are transmitted to Smart Communications.
Andrej Rylov 1.1 54
Andrej Rylov 3.1 55 === Handling sessions via JS tracker ===
Andrej Rylov 1.1 56
Andrej Rylov 3.1 57 When a new session starts, the [[JS tracker>>doc:Main.Smart_Communications.SMC_integration.JS_tracker.WebHome]] creates and sends a cookie file to the client. At the same time, the ##user_visit## event is automatically generated and recorded in the database. Subsequent customer actions will be linked to the session via this cookie. The cookie lifetime is 1 hour, with automatic renewal after each new action.
Andrej Rylov 1.1 58
Andrej Rylov 3.1 59 If the customer has previously logged in to the website and still has a cookie file from a previous session, the JS tracker will automatically fill in the customer identifier field. Additionally, the JS tracker will fill in the customer identifier field if the user arrived at the site via a link from an email campaign.
Andrej Rylov 1.1 60
Andrej Rylov 3.1 61 In other cases, identifying the customer requires transmitting the [[authorization and registration>>doc:Main.Smart_Communications.SMC_integration.JS_tracker.WebHome||anchor="HAuthorizationandregistration"]] event (##user_login##) to the JS tracker. The corresponding code needs to be added to the authorization page.
Andrej Rylov 1.1 62
Andrej Rylov 3.1 63 (% class="box warningmessage" %)
64 (((
65 If the website provides for automatic customer authorization (the "Remember me" function), ensure that the authorization event is transmitted to the JS tracker.
66 )))
Andrej Rylov 1.1 67
Andrej Rylov 3.1 68 If the cookie lifetime expires and the customer performs a new action, the JS tracker creates a new cookie file and starts a new session.
Andrej Rylov 1.1 69
Andrej Rylov 3.1 70 === Handling sessions via Mobile SDK and REST API ===
Andrej Rylov 1.1 71
Andrej Rylov 3.1 72 When working via Mobile SDK and/or REST API, the logic for grouping events into sessions must be implemented on the Partner's side. Web events are transmitted to Smart Communications using the [[event>>doc:Main.Smart_Communications.SMC_integration.MobileSDK.WebHome||anchor="event"]] method of the Mobile SDK and the [[Web_event>>doc:Main.Smart_Communications.SMC_integration.Data_exchange.SmC_API.SmC_API_methods.Web_event.WebHome]] method of the REST API.
Andrej Rylov 1.1 73
Andrej Rylov 3.1 74 When starting a new session, you must transmit the ##user_login## or ##user_visit## event with the session identifier (##session_id##) and customer identifier in the master system (user_id) fields filled in. All subsequent events must have the session identifier field (##session_id##) filled.
75
Andrej Rylov 1.1 76 {{info}}
77 It is recommended to adhere to the following principles when forming sessions:
78
79 * ensure uniqueness of session identifiers;
80 * start a new session if more than 1–2 hours have passed since the customer's last action.
81 {{/info}}
82
83 (% class="box" %)
84 (((
85 **See also:**
86
87 * [[E-commerce>>doc:Main.Smart_Communications.SMC_Use.E-Commerce.WebHome]]
Andrej Rylov 2.1 88 * [[Integration with e-commerce systems>>doc:Main.Smart_Communications.SMC_integration.Ecom_integration.WebHome]]
89 * [[JS tracker>>doc:Main.Smart_Communications.SMC_integration.JS_tracker.WebHome]]
90 * [[Mobile SDK>>doc:Main.Smart_Communications.SMC_integration.MobileSDK.WebHome]]
Andrej Rylov 1.1 91 )))