Track screens
Contentsquare aggregates user behavior and engagement at the screen level. To achieve this, it is necessary to provide a name for each screen by calling a dedicated screenview API.
Screen name handling
Section titled Screen name handlingThe screen name is limited to 2083 characters. However, this limit is not enforced by the SDK, but rather by the Contentsquare servers.
Screenview after app in background
Section titled Screenview after app in backgroundDepending on your implementation, a screenview event might be sent after the app is put in background and then in foreground. To do so, you will have to call Contentsquare.send(..)
in the onResume
lifecycle method of the activity (or fragment).
Implementation recommendations
Section titled Implementation recommendationsGeneral rules
Section titled General rulesFrom a functional standpoint, we expect a screenview to be sent:
- When the screen appears
- When a modal/pop-up is closed and the user is back on the screen
- When the app is put in the foreground (after an app hide)
When to send your first screenview
Section titled When to send your first screenviewMost events collected by the SDK require a screenview event to be sent first so they can be associated with that screen; otherwise, they will be discarded. If you need to collect events from the moment the app launches, you should trigger a screenview event immediately after the SDK has started.
Automatic start
Section titled Automatic startIf the SDK is started automatically, you should send your first screenview when your app’s life cycle begins. For instance, you can send it in your Application onCreate()
method:
Manual start
Section titled Manual startIf the SDK is started manually, you should send your first screenview right after calling start()
:
Activities
Section titled ActivitiesTo trigger a custom screenview each time the activity is visible place the tag in the onResume
method.
Fragments
Section titled FragmentsTo avoid double tagging on Fragments, make sure to include the tag in each ViewPager’s onPageChangeListener
callback.
Popups
Section titled PopupsWhen tracking a popup as an isolated screen, use the API to send a screenview event onShow
. To re-trigger a screenview of the current activity below when the popup is dismissed, make sure to trigger a screenview event with the original Activity screenName on the popup DismissListener
.
Bottom sheets
Section titled Bottom sheetsWhen tracking a bottom sheet as an isolated screen, use the API to send a screenview event on view displayed. On its dismiss, make sure to trigger a screenview event with the original screen name on BottomSheetBehaviorCallback
state change (Usually when STATE_HIDDEN) to track the complete cycle.
Back navigation and navigation between screens
Section titled Back navigation and navigation between screensMake sure that screenview events will be triggered when a user will go to the previous screen (example: Home → Profile → Home), it is expected to have a screenview event for the Home screen that might be reached with the back navigation button. Trigger screenview event in a custom callback ↗ to catch the back events.
Redirecting the user to another screen (authentication, home) when closing the app/re-opening the app
Section titled Redirecting the user to another screen (authentication, home) when closing the app/re-opening the appFor some apps, you might want to redirect users whenever they hide your app, for example for security purposes (bank apps, password managers, etc…). If that is the case, pay specific attention to the way screen_view
events are sent, in order not to track a screen which is not actually shown users.
How to name screens
Section titled How to name screensAs a general rule, keep the number of distinct screen names under 100. Since these names are used to map your app in Contentsquare, choose names that are clear and comprehensive.
Separate words with spaces, dashes or underscores
Section titled Separate words with spaces, dashes or underscoresWhen generating screen names with multiple words, separate them using spaces, dashes, or underscores.
For instance, use Home and Living - Home Furnishings
instead of for a sub-category in a retail app.homeLivingHomeFurnishings
Screen name limitations
Section titled Screen name limitationsUse screen template/layout names
Section titled Use screen template/layout namesAs a general recommendation, use names referring to the screen template/layout rather than referring to the specific content (data). This will help:
- To keep the number of distinct screen names low and therefore make Contentsquare easier to use
- Remove the risk of sending Personal Data to Contentsquare
List of screen types falling into that category: Product detail, Event detail, Conversation/Chat, User profile…
Screens with multiple states/layouts
Section titled Screens with multiple states/layoutsScreens can have different layouts or states depending on the user context. In this case, append its value to the screen name.
Home screen
State | Screen name |
---|---|
App landing layout | Home |
Women products layout | Home - Women |
Men products layout | Home - Men |
Sales layout | Home - Sales |
Product Detail screen (PDP)
State | Screen name |
---|---|
Users on a Top for Women PDP | PDP - Clothing - Women - Tops |
Users on a Microwave PDP | PDP - Kitchenware - Electrics - Microwave |
Users on a Hotel details screen | PDP - Holiday type - Season - Board |
User account screen
State | Screen name |
---|---|
Overview | My Account - Dashboard |
Order history | My Account - Order history |
Returns | My Account - Returns |
Search screen
State | Screen name |
---|---|
Search | Search |
Search results for “Skincare” products | Search - Skincare |
Search results error screen | Search - Error |
Cart screen
State | Screen name |
---|---|
Empty cart | Cart - Empty |
Items have been added to the cart | Cart - Populated |
Issues with availability or pricing | Cart - Error |
Checkout screen
State | Screen name |
---|---|
User provides name, surname, and date of birth | Checkout - User Details |
User provides shipping address | Checkout - Shipping Details |
User inputs their credit card information | Checkout - Payment |