Home - activitystream/asa.js GitHub Wiki

Welcome to Activity Stream Analytics JavaScript client!

This is a small script which, when included on your web site, enables collection of analytical data about your current and potential customers' behaviour.

The script's behaviour is similar to the scripts provided by other analytics products like for example Google Analytics. The script collects a rather conservative amount of data automatically leaving you, the consumer of the information, to decide how much and what kind of data you would like to collect.

We call each unit of the data sent to Activity Stream an event. Each event contains data about what the end-user has directly or indirectly done.

Quickstart

To start collecting analytics information from your web site in Activity Stream all you need to do is to place the following piece of JavaScript somewhere between the <head> and </head> tags in your HTML.

Please do not forget to replace the #your Tenant ID# with your Tenant ID that Activity Stream has provided you with.

<script>
(function(i,s,o,g,r,a,m){i['ActivitystreamAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//cdn.activitystream.com/asa.min.js','asa');

asa("set.tenant.id", "#your Tenant ID#");

// The steps below are optional

/* Uncomment the following to set the external service providers that your website uses like login providers, 
payment providers (eg. google.com, paypal.com) etc. We use this to make sure that we don't mistake one of them 
for a referrer that brought the customer to your website. This info is optional, but will make the analytics 
much more precise. Don't forget to replace ["google.com", "paypal.com"] with an array of your providers' 
domains. */
// asa("set.service.providers", ["google.com", "paypal.com"]);

/* Uncomment the following to set the connected partner domains. Links on your website that lead to these 
domains will contain UTM data(campagin, source etc), partner data (partner_id, partner_sid). That data will be 
sent along with the events sent out from the partner domains. 
Don't forget to replace ["example_partner_A.com", "example_partner_B.com"] with an array of your partners' 
domains.*/
// asa("set.connected.partners", ["example_partner_A.com", "example_partner_B.com"]);

</script>

This snippet loads the main Activity Stream analytics script in a way that does not affect your end users' experience and sends a as.web.session.started event.

Required events

An event that tells us a user has viewed a product:

asa("as.web.product.viewed", ["Product/1"]);

as.web.product.viewed takes as an argument a list of ProductId[1]. This event is used to calculate campaign conversions

An event that marks a purchase has been made by a customer:

asa("as.web.payment.completed", ["Order/1"]);

as.web.payment.completed takes as an argument a list of OrderID[1] This event is used to calculate campaign conversions, and ROI, and more cool stuff.

Footnotes

[1] ID's sent through asa.js must match the internal Id's of entities so that we can join the data.

⚠️ **GitHub.com Fallback** ⚠️