Note: Do not directly switch the data receiving address of different items on the online page, which will cause the first day of id association abnormal. It is recommended that the data be sent to the test project during the offline test, if no problem, the data collected online will be directly sent to the formal project.

1. Add user

In general, we define new users as users who use the product for the first time, or the first trigger for some key behaviors (such as registration, purchase). In strategic analysis, you can combine the first day access ($is_first_day) attribute to get new users who visit every day, and the first trigger event ($is_first_time) attribute to get users who trigger the first critical event.

1.1. Added user indicator configuration

New User definition on the Web side: Among independent visitors of the same day, the visitor that accesses the website on the first day is defined as a new user.

New users added on the App: Among the users who start the App on the same day, the users who start the App on the first day are the new users.

New user definition on the applet side: Among the users who start the applet on the same day, the user who starts the applet on the first day is the new user number.

User first access time distribution: Time distribution of users' first use of Web/App/ applet

First trigger event definition: The first time a new user triggers APP launch /Web browsing/applet launch

1.2. Added user tag collection

The marking of new users is mainly completed on the client side, and the fields that differentiate new users will be collected by the SDK by default are

Front-end event public property: First day access or not ($is_first_day)

Field nameTypeDescriptionJS SDK Auto CollectioniOS SDK Auto CollectionAndroid SDK Auto CollectionMini Program SDK Auto CollectionServer-side SDK Auto Collection
$is_first_dayBooleanWhether it is the first day of visitYYYYN

Implementation logic:

1. Web: For the first visit of the user to the page with the SensySDK embedded on the same day (i.e., the first day), the JS SDK will set a flag for first-day visit in the cookie of the web page and set the value of $is_first_day=true for events triggered on the first day before 24:00. After the first day, the flag will be false, i.e., $is_first_day=false for events triggered on the web page after the first day;

2. Mini Program: For the first visit of the user to the page with the SensySDK embedded on the first day, the Mini Program SDK will create a flag in the storage cache with the value true and keep it as true before 24:00 of the first day. So for events triggered on the first day, $is_first_day=true. After the first day, the flag will be false, i.e., $is_first_day=false for events triggered on the Mini Program after the first day;

3. APP: For the first time the user opens the App with the SensySDK embedded on the same day of App installation, the Android/iOS SDK will create a flag in the local cache with the value true and keep it as true before 24:00 of the first day. So for events triggered on the first day, $is_first_day=true. After the first day, the flag will be false, i.e., $is_first_day=false for events triggered on the App after the first day.

Front-end event property: Whether it is the first time to trigger the event ($is_first_time)

Field NameTypeDescriptionJS SDK Auto-collectioniOS SDK Auto-collectionAndroid SDK Auto-collectionMini Program SDK Auto-collectionServer SDK Auto-collection
$is_first_timeBoolean valueWhether it is the first time triggering the eventYYYYN

Implementation logic:

Store a flag locally for the $pageview/$AppStart/$MPLaunch event. The flag is initially set to 'no' and is changed to 'yes' for the first time, and then set to 'no'.

User attribute: First visit time ($first_visit_time)

Field nameTypeExplanationJS SDK Automatic CollectioniOS SDK Automatic CollectionAndroid SDK Automatic CollectionMini Program SDK Automatic CollectionServer-side SDK Automatic Collection
$first_visit_timeDatetimeFirst Visit TimeYYYYN

Implementation Logic:

1. For web and Mini Program: After integrating the Sensing Js or MiniProgram SDK, enable autotrack to enable full tracking. The SDK will call the profile_set_once interface to set the first visit time attribute for the user when they first browse the webpage or launch the Mini Program.

2. For app: After integrating the Sensing iOS or Android SDK, call the trackInstallation interface. This interface will set the first visit time attribute for the user when they first use the app. If the trackInstallation interface is not called, the first visit time will not be set automatically.

1.3. Correction of First Day Flag

In many scenarios, relying solely on client-side flagging is not accurate. In addition to client-side flagging, Sensing has added server-side correction to ensure more accurate data.

1.3.1. Correction of First Day Visit in Server-side

As mentioned above, the new user is judged by the attribute $is_first_day (whether the first day access is true) reported by the App/Web/ applet. In the following scenario, the value of $is_first_day will be incorrect, which needs to be corrected by the wizard server.

Scenario 1: The App cache is cleared or the user uninstalls the app. This causes the front-end tag to be cleared. After the tag is cleared, the first attribute is reported as true on the first day. If the $is_first_day (first day access or not) attribute is reported and the value is true, the server will compare the current date with the first $is_first_day (first day access or not) date in history. If not on the same day, then fix this time $is_first_day to false.

Scenario 2: Upgrade from the unconnected SDK version to the connected SDK version. For example, Xiao Ming has been using your App since 2012 and is a veteran user. On January 1, 2020-your home launched a new version of Android integrating Sensors SDK, and Xiao Ming upgraded the App. The SDK marks for the first time, identifies the $is_first_day attribute of Xiao Ming as true, and reports it. Obviously this is not accurate. Because although Xiao Ming is a new user for Shence, he is essentially an old user.

For this case, you can choose not to deal with it, and most of the historical active users upgrade to use it, and the data tends to be accurate over time.

If you need to process, Sensors also provides a processing plan, that is, to import the first day of access time of historical users like Xiao Ming into the system in advance. By the way of advance import, Shenze knows in advance which users are old users, when these historical old users enter Sensors, the original $is_first_day (whether the first day access) is true will be corrected to false.

The import procedure is as follows:

1. Generate a file with Distinct Id and first access time (represented by unix timestamp) for each user:

6D92078A-8246-4BA4-AE5B-76104861E7DC 1513577063 5D3169E2-16BC-316C-12AB-1E2EC1A79E2B 1512057600

Note:

  • After the file is uploaded, it is only valid for data stored after the upload date. Data stored earlier than the first access time file upload time cannot be modified;
  • The first access time in the file is stored on the server and used to verify the data in the database. It is not immediately written into the user table.
  • The server corrects the value of the imported event attribute $is_first_day (whether it is the first day access) to true according to the first access time of the upload. The correction rule is that only the value of the attribute $is_first_day is true is corrected. And as long as the time of the imported event is not the same day as the first access time recorded by the server, it will be corrected to false (including time earlier than the server will also be corrected). The property value of $is_first_day being false will not be fixed.
  • The server will modify the real-time imported user attributes based on the first access time of the upload $first_visit_time(First access time),fix $first_visit_time Indicates the first access time of the server upload.
  • First access time of server upload,不会 Fix the $is_first_time attribute. Currently, it is not supported to upload the first access time on the server in advance, and the attribute of $is_first_time = true is corrected. Only after the $is_first_time = true event data has been imported can the server record the first access time of the event.

2. If the Distinct Id in the file is a device ID (see2021-10-19_10-11-05_.Identify user v1.13),Continue to the next step. If Distinct Id is a login ID, you need to use the SDK or import tool to import a profile_set for each ID and set is_login_id to true and properties to blank. For example, the Java SDK can call:

sensorsAnalytics.profileSet("123456789", true, Collections.emptyMap());
JAVA

3. Log in to the Sensors server and run the following commands as user sa_cluster:

sdfadmin import_first_time --project 导入的项目名 --file 数据文件路径 --event 事件名,可选
CODE

1.3.2. The first trigger event was corrected on the server

At present, the "First trigger event" preset by the wizard is only collected for $pageview/$AppStart/$AppStartPassively/$MPLaunch events, and not all events have this attribute. If you need to add the $is_first_time attribute to a custom event, see below自定义事件设置首次触发事件属性示例

In some analysis scenarios, we hope that we can judge whether the event (custom event, front-end and back-end event) is triggered for the first time by a user through an event attribute. For example, this attribute in App startup can judge whether the user starts the App for the first time. This property in the Add to Cart event determines whether the user added the item to the cart for the first time. This requires us to add the $is_first_time attribute for the "start" and "shop" events to determine whether it is a new user that triggers the critical event.

1.3.2.1. Add a field when importing

In the process of importing events, if you think that this event [*] may be the user's (distinct_id) first trigger, set the value of $is_first_time to true. The principle is that the imported module of Sensors Analytics backend will judge and modify this value during the data import. Specifically, if the event data with $is_first_time set to true is encountered, Sensors Analytics backend will query the database for the first visit records of the user for this event. If the recorded trigger time is different from the current event, the value of $is_first_time will be modified to false; otherwise, the first trigger time of the user will be recorded and the value of $is_first_time will be kept as true.

1.3.2.2. Example of setting the first trigger event attribute for custom events

For example, with the Java SDK:

// 首次触发"BuyGold"事件标记"$is_first_time"为 true,最终导入值为 true properties.put("$is_first_time", true); sa.track("user1", false, "BuyGold", properties); // do something else ... // 再次触发"BuyGold"事件标记"$is_first_time"为 true,最终导入值为 false properties.put("$is_first_time", true); sa.track("user1", false, "BuyGold", properties);
CODE

Although $is_first_time is set to true twice, only the value of the first import is true after actual import.

1.3.2.3. Precautions

  1. The above logic will be triggered only when the value of $is_first_time is true;
  2. If the value of $is_first_time has never been set to true in the previously imported data, the first trigger time will be recorded only when it appears for the first time, and the judgment will be based on this time in the future;
  3. In this logic, the judgment of whether it is the first trigger is based on whether the event trigger time (accurate to milliseconds) is equal to the value in the database. If the two trigger times are the same and both set the value of $is_first_time to true, no modification will be made. This situation generally does not occur. For example, if the app sends two events continuously and it is certain that the second event is not the first one, the value of $is_first_time should not be set to true;
  4. This logic is affected by the order of data import. For example, if the 6-day data is imported first and marked as the first trigger, and then the 3-day data is imported and marked as the first trigger, the first trigger of the 6-day data will be marked as true, while the 3-day data will be marked as false;
  5. This feature is supported in version 1.8 and later, and the build time (can be viewed on the About page of the backend) is after 2017-11-26. Otherwise, upgrade is required.

1.4. Frequently Asked Questions

1.4.1. The first day ($is_first_day) of events for the same user on the same day is sometimes true and sometimes false

It may be caused by time zone differences. For example, the client time of the user in location A is 12 hours behind Beijing time, and the time of the client's server is Beijing time. When the user triggers the event at 23:00 on 2019-08-02 in the client time of location A, the corresponding $is_first_day property is true, and the time recorded for this event is 2019-08-02 11:00. When the user triggers the event at 02:00 on 2019-08-03 in the client time of location A, the corresponding $is_first_day property is false, and the time recorded for this event is 2019-08-02 14:00. When querying data in Sensors Analytics, there will be a situation where $is_first_day of events triggered by the same user on 2019-08-02 is sometimes true and sometimes false.