20 A/B Testing Tools for Mobile Apps / How to Install Autosend Using JavaScript

How to Install Autosend Using JavaScript

The easiest way to implement Autosend for your web application is to use our JavaScript snippet. If you’ve ever used Google Analytics or anything similar, then this should be a piece of cake. This basic setup should only take about 5 minutes.

Get Started

The snippet below is an example of our JavaScript snippet. You should however, copy and paste the snippet that is available on your account as it already comes with your unique auth key. Place this code on every page where you can identify a logged in user.

Identify a User

The next step is identifying a user. This is more than likely a user who is logged in to your website. This is how Autosend knows who triggered an event (next section) and who to send a message to. You would also want to add this code to every page a user is logged in. The only required parameter is id, but you should probably provide email, name, and phone (country calling code followed by the number, for example 15555555555 where 1 is the country calling code). If a user already exists with the provided id, their information will be updated with any provided parameters.  

Here is a list of all the available parameters:

  • id - A unique ID that you use to identify the logged in user
  • email - The user's email address
  • name - the user's name
  • phone - the user's mobile phone number (country calling code followed by the number, for example 15555555555 where 1 is the country calling code)
 

Custom Parameters

Outside of the mentioned parameters above, you can provide any custom parameters you want. These user attributes can then be used when creating your message by using the attribute format of [[data ATTRIBUTE_NAME]]. For example, if you provided a parameter called twitter_name, when creating your message within your Autosend account you can refer to that parameter with the following: [[data twitter_name]]

Track an Event

Finally, you'll want to track an event. An event is an action a user takes in your app, whether it's a button click, a page landing, or perhaps even a more specific action such as using a promo code.

Posted in: Installation