The first part of the code is for required parameters for every event. There are a couple of steps to get this part working:
-
Replace
site_id
with the site id provided by ReSci (Retention Science). -
Edit the
if(condition)
line below with your specific parameters for checking if a user is logged in. -
Replace the
user_id
anduser_email
as described above if the user is logged in, otherwise just send empty strings as shown below:
site_id: Your site_id will be assigned by Retention Science and must be set on every eventuser_email: If the user is logged in, replace user_email with your dynamic variable
user_id: An if condition should determine whether a user is logged in. If a user is logged in:
- The user_id should correspond to the user’s unique record ID within your database
- If you don’t have a unique ID, create one using the MD5 of the user’s lowercased email
Example email: JohnDoe@example.com
Example lowercased email: johndoe@example.com
MD5 of lowercased email: fd876f8cd6a58277fc664d47ea10ad19
Use cases
- Identify user
- Tracking call
- Adding wave callback
- Item type (subscription business only)
- Setting user properties in JavaScript
Identify user
var _rsq = _rsq || []; _rsq.push(['_setSiteId', 'site_id']); // replace site_id with your static Site ID _rsq.push(['_enableOnsite']); if (condition) { // replace condition with your parameters for checking if a user is logged in _rsq.push(['_setUserId', 'user_id']); // replace user_id with your dynamic user_id variable _rsq.push(['_setUserEmail','user_email']); // replace user_email with your dynamic user_email variable }
Tracking Call
For events to be fired and tracked, you must push ‘_track’ into the _rsq variable.
_rsq.push(['_track']);
Ajax calls: For sites that use Asynchronous JavaScript and XML (AJAX), please verify that you call _rsq.push([‘_track’]);
after each event to allow us to capture these events.
Adding wave callback
This piece of code sets up the call back to Retention Science. It is required for the integration and is needed on every snippet.
(function() { var rScix = document.createElement('script'); rScix.type = 'text/javascript'; rScix.async = true; rScix.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'd1stxfv94hrhia.cloudfront.net/waves/v3/w.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(rScix); })();
Item type
This is only required for clients that have a Subscription business model. Item type identifies the type of item for any action (e.g. subscription or individual), and would be required for any “addItem” line in the Javascript.
_rsq.push(['_addItem', {'id': 'item_id','item_type': 'subscription'}]);
Setting user properties in JavaScript
-
Adding this line allows setting user information (e.g. custom attributes) via JS.
-
Typically combined with the email tracking JS to set user properties upon creation. (e.g. registration source).
-
Once complete, steps must be done on the RS side to start importing the new wave data.
-
Email and record_id are required at a minimum for the SetUserProperties line, else the data will not be valid and imported.
-
For standard User fields, can only be set once at an email tracking creation event. For custom attributes, can be used to update existing attributes.
_rsq.push(['_setUserProperties', { 'record_id':'12345','email':'thisisrequired@gmail.com','registration_source':'footer'}]);
Comments
0 comments
Please sign in to leave a comment.