Retainly Support

            How to use the Retainly Tracking Script

            Developer Knowledge Required. 

            The Retainly Tracking Script is very useful for SaaS products and for those bloggers who offer a membership module. The tracking script automatically tracks new Signups and adds them as contacts in your Retainly Default List. The script can also track events triggered by your customer's behavior which can be used for Real Time Behavioural Marketing.   

            Login to your Retainly application and navigate to Settings, where you will find your own JS Tracking Script.  Below is the sample Script.
            1. <script>
            2.     window.retainlySettings = {        
            3.       app_id: "589ae9dd63321",        
            4.       company: "Name of the company",         
            5.       email: "[email protected]",         
            6.       signedup_at: "2017-02-22",        
            7.       plan: "Premium" 
            8.       };
            9. </script>

            Elements of this Script
            1. app_id: Is your unique id which is autogenerated by Retainly. Do not change it. 
            2. company: It is an optional field that can help you to group your contacts. You can change the value field. If you use server variables, you can use something like  company: "<?php echo $company;?> "
            3. email: Email Id of the user that you willing to track. This is a mandatory field. if you use server variable, you can use like  email: "<?php echo $logged_mail;?>"
            4. singedp_at : This is optional, but shall be usefult to plan your drip based on the signup date on your app/website. It is the value of the variable to denote when the user is created. Server Variable can be used as  signedup_at: "<?php echo $singedupdate;?>"  
            5. plan: Another optional field which helps you to capture the plan or package selected by your customer, and can be changed as per your need. Server variables can be used as plan: "<?php echo $plan; ?>"

            The Script Function
            The script below automatically tracks the page visits based on the user configuration.

            You need to add this script as it is in all your pages, ideally in your footer. And ensure the above script too has set before this

            1. <script>
            2. (function(){var w=window;var d=document;var r=function(){r.c(arguments)};r.q=[];r.c=function(args){r.q.push(args)};w.retainly=r;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src=''+retainlySettings.app_id;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}})()
            3. </script>

            The Event Tracking Script

            You need to add this script in all your webpages where you want to capture an event from your site/app. 
            This script will track your defined events triggered by your users. These events can be later used inside Retainly to automatically send real time behavioural campaigns. 

            1. <script>
            2. TrackEvent('Student Added',JSON.stringify({'name':'John Doe','age':'22'}))
            3. </script>

            The script provided above is an example. 'Student Added' is the event name. You can create and name any event depending on your application. The second part of this script is a JSON object. 

            What are the possible fields that can be tracked?
            The below list has the complete set of fields that can be used inside window.retianlySettings

            Field       Remarks
            name Nick name or nice name of the contact
            email Email ID of the contact. This is mandatory field
            signedup_at This is the signedup date of your contact in your application/db
            plan If the contacts is to be associated with any plan in your app, you can use this field
            title Title of the contact. E.g., Mr. Ms. etc.,
            first_name Firstname of the contact
            last_name Lastname of the contact
            gender Gender of the contact
            birthday Birthday of the contact. Pass the values in YYYY-MM-DD format
            street Address of the contact
            city City of the contact
            state State or region of the contact
            country Country of the contact
            postal_code Posta code / zip code of the contact
            country_code Country code of the contact
            phone Phone / Mobile number of the contact
            website Website of the contact
            tags Tags that you want to add to this contact. Use comma separated lists like Beta, Demo
            company Company of the contact. Will be useful to group them into accounts
            revenue Revenue that wsa charged against this contact
            avatar Avatar URL of the contact

            Updated: 14 Apr 2017 04:02 AM
            Help us to make this article better
            1 0