This guide will help you to integrate Retainly features seamlessly into your web application with Retainly JS SDK.
Initialization #
To initialize the Retainly JS SDK, you can use the _rio.init
method.
_rio.init(config);
Config Fields #
The config
object can have the following properties:
Field | Default | Description |
---|---|---|
visits | true | Toggle automatic page view tracking. |
utm_params | ['utm_source','utm_campaign', 'utm_medium','utm_term', 'utm_content','gclid', 'campaign_id'] | List of UTM parameters to track automatically. |
track_all_params | true | Enable tracking of all query parameters on the page. |
get_params | [] | Define specific query parameters to track, effective only if track_all_params is set to false . |
gaMeasurementId | '' | If specified, sets up Google Analytics and sends page views and events. |
ping_enabled | true | Automatically ping the server at regular intervals between startSession and endSession calls. |
ping_interval | 120 | Interval between pings, in seconds. |
ping_properties | {} | Additional properties to include in ping requests. |
expire_cookies.tracking | 94608000 | Expiration time for tracking cookies, in seconds. |
expire_cookies.ab_test | 94608000 | Expiration time for A/B test cookies, in seconds. |
expire_cookies.time | 3600 | General cookie expiration time, in seconds. |
Event and Page Tracking #
Manually track events and page views.
Page View #
To manually track a page view, use:
_rio.page(url, params);
Event #
To manually track an event, use:
_rio.track(name, params);
Session Tracking #
Start and end user sessions manually.
Start Session #
To start a new user session, use:
_rio.startSession();
End Session #
To end the current user session, use:
_rio.endSession();
User Identification #
Identify individual users who were previously unknown and tracked only by cookies.
_rio.setId(id);
Push Notifications #
Allow your application to subscribe the user for push notifications.
_rio.subscribe();
Certainly, I can help rephrase your guidelines to make them easier to understand.
Quick Start Guidelines #
Here are some easy-to-follow guidelines on how to properly integrate Retainly’s WEB SDK into various user interactions on your platform.
1. New User Registration #
When someone new signs up on your website, you’ll need to:
- Tell Us About the New User: Make sure to send us the new user’s details right after they sign up.
- Track the Registration: Also, send us a ‘Registration’ event to note that a new user has joined.
2. Adding Items to Cart #
Whenever someone adds an item to their shopping cart:
- Just Send the Info: You can notify us no matter whether we know this user or not.
- But Preferably, Let Us Know the User: For the best tracking, it’s good if this user already exists in our system.
3. Completing a Purchase #
When a purchase is made:
- Notify Us of the Purchase: Send us a ‘Purchase’ event right after the transaction.
- Who Made the Purchase?: Again, it’s better if this customer is already registered in our system for comprehensive tracking.
Tracking Guest Users #
Our WEB SDK can still track users even if they haven’t signed up. We just label their activities under an ‘unknown customer’ profile. If they later sign up, all their past activities get merged into their new profile.
🔑 Important: Always make sure to create customer profiles in our system for the best experience.
About Cookies and Tracking #
We use cookies to keep track of users. This is especially important for guests. But be aware:
- User Data May Be Lost: If someone clears their cookies or uses private browsing, we might lose their activity data.
- Inform Your Users: Let your users know that cookies are being used to track their activity for a better user experience.