Custom activities guide (website)
Activities describe user behavior like clicking on an email, making a purchase or logging in to your application. They help you understand what your customers are doing, segment customers into audiences and create detailed reports. Custom activities allow you to design your own activities that represent behaviors across the customer lifecycle.
Activities are used to enter people into playbooks and create target audiences, reports and dashboards.
This guide shows you how to add your own custom activities to Ortto via your website Javascript. Custom activities will help you find deep insights into your business via reporting and filtering, and have fine-grained control about how and when you communicate to your audiences.
Getting started
- To send activities from your website you will need to have the Ortto tracking code installed.
- Next, you need to create a custom activity.
- For the activity to be send from your website, during the activity setup you need to enable the Client-side data source option.
- Once this is done we are ready to add the code to your website Javacript.
Sending activities via website Javascript
Below is a basic example of sending a login activity to Ortto via website Javacript. This assumes that the activity has Client-side data source enabled. Note that this code relies upon you having the Ortto tracking code set up.
Ortto can only track activities for identified users. To identify a user you need to do the following:
javascript
ap3c.track({"v":0,"email":"user@emaildomain.com","first":"John","last":"Apple"});
Only the email address is required to track a user. The first and last name are optional.
Once this is done, you can then send activities for that user. Here is a full working example:
javascript
ap3c.cmd.push(function() { ap3c.init('(hidden)', 'https://capture-api.autopilotapp.com/'); ap3c.track({"v":0,"email":"user@emaildomain.com","first":"John","last":"Apple"}); }); ap3c.activity({ "activity_id": "act:cm:login", "attributes": { "str::email": "john@example.com", "str:cm:payment-plan": "$100 starter plan", "bol:cm:account-owner": true, "str:cm:web-browser": "Google Chrome" } });
NOTE:
You should update your tracking code
Note that in this example the
ap3c.activity
call must be inside theap3c.cmd.push
block. This is because the existing tracking code dynamically defines theap3c.activity
function. If you would like to be able to callap3c.activity
from anywhere in your code at any time, you can update your tracking code by going into Ortto and updating to the latest code, or simply adding this additional line to the tracking code:ap3c.activity = function(act) { ap3c.act = (ap3c.act || []); ap3c.act.push(act); };
After the
ap3c.cmd.push
line.Create activity responses
404 response
If you see a 404 in the console it is either because the activity you tried to track has not been created in Ortto, or because the activity has not been enabled for tracking, i.e. the client-side data source. Please check that both of these are correct before continuing.
Success response
If the activity is tracked you will not see anything. You can check the network inspector of your browser for the successful 'activity' request receiving a 200, but the best way is to login to Ortto and refresh the activity page to make sure that your activity came through.
Rate limits
Since public activities are sent from your website, it means that someone who wants to be malicious could use Javascript on your website to send a lot of activities. In practice, this is rare, but to protect you we have the following rate limits in place for website activities:
Type
Description
Person
10 per person per day of the same activity_id.
IP
100 per hour per ip of the same activity_id.