Wiki source code of Web events and sessions


Show last authors
1 (% class="lead" %)
2 Web events and sessions are used in Smart Communications to process customer actions on an online store website or in a mobile app.
3
4 (% class="box" %)
5 (((
6 **Contents:**
7
8 {{toc depth="3" start="2"/}}
9 )))
10
11 == **Web events** ==
12
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.
14
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).
16
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.
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
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"]].
23 {{/info}}
24
25 === **Methods for receiving information about web events** ===
26
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.
28
29 ==== **JS tracker** ====
30
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).
32
33 ==== **Mobile SDK** ====
34
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.
36
37 ==== **REST API** ====
38
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).
40
41 == **Sessions** ==
42
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.
44
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.
47
48 For all other events, transmitting the customer identifier is not required. Events are linked to the customer via the session identifier.
49 {{/warning}}
50
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.
52
53 Session handling logic differs depending on how web events are transmitted to Smart Communications.
54
55 === Handling sessions via JS tracker ===
56
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.
58
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.
60
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.
62
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 )))
67
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.
69
70 === Handling sessions via Mobile SDK and REST API ===
71
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.
73
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
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]]
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]]
91 )))