Install Instructions for UserIQ Tracking Snippet
This article will guide you through the process of installing the UserIQ tracking snippet on your multi-page application.
To start tracking, add the following javascript snippet to the body of your application (typically in an index.html file) in the proper environment (typically we recommend starting in a QA or test environment). Place it just before the closing body tag (</body>).
** Replace the red text with the corresponding variables in your system.
<script type="text/javascript">
(function(){
/**************/
// UserIQ helper logic
var useriq = (window._uiq = window._uiq || [])
useriq.invoked &&
window.console &&
console.error &&
console.error('Useriq snippet already exists.'),
(useriq.invoked = !0),
(useriq.methods = [
'setSiteId',
'startTracker',
'setDoNotTrack',
'identify',
'track',
'group'
]),
(useriq.factory = function(e) {
return function() {
var r = Array.prototype.slice.call(arguments)
return r.unshift(e), useriq.push(r), useriq
}
})
for (var i = 0; i < useriq.methods.length; i++) {
var key = useriq.methods[i]
useriq[key] = useriq.factory(key)
}
/**************/
// All red highlights indicate the areas in the UserIQ script
// that should contain your own variables
// site id is provided by UserIQ
var useriqSiteId = "INSERT SITE ID PROVIDED FROM USERIQ HERE"
// set site id
useriq.setSiteId(useriqSiteId)
// userId is required
var userId = INSERT USER ID VAR HERE
// accountId is required for account analytics
var accountId = INSERT USER ACCOUNT ID VAR HERE
// identify user
useriq.identify(userId, {
user_name: INSERT USER NAME VAR HERE,
account_id: INSERT ACCOUNT ID VAR HERE,
account_name: INSERT ACCOUNT NAME VAR HERE,
user_email: INSERT USER EMAIL VAR HERE,
signup_date: INSERT USER SIGNUP DATE VAR HERE //(YYYY-MM-DD)
})
// start tracker
useriq.startTracker()
/**************/
// UserIQ helper logic
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src="https://feed.useriq.com/useriq.js"; s.parentNode.insertBefore(g,s);
/**************/
})();
</script>
Important information about the user id custom variable:
- This variable is required to track individual users accurately
- This is the individual user's unique identifiable trait in your system (this can be a string of digits, a database primary key, an email, a name, etc.)
- It MUST be unique across your ENTIRE system
- If you pass a user's e-mail address as user_id it is mapped to both user_id and user_email
How do I configure additional custom variables?
To pass additional custom variables, simply add an additional key: value pair inside the UserIQ "identify" call within your existing UserIQ tracking snippet. See examples below for multi-page and single-page applications.
*Note: don't forget to put a comma after the last current custom variable before adding your new custom variable!
// identify user
useriq.identify(userId, {
user_name: YOUR USER NAME VAR HERE,
account_id: accountId,
account_name: YOUR ACCOUNT NAME VAR HERE,
user_email: YOUR USER EMAIL VAR HERE,
signup_date: YOUR USER SIGNUP DATE VAR HERE, //(YYYY-MM-DD)
// add additional custom variables here like so:
user_role: INSERT USER ROLE VAR HERE
})
Comments
0 comments
Article is closed for comments.