Web interaction

 Version 2.2

You can integrate with Carma to track user behavior on your site. The collected information can be used in filters and segments to target user content. This is an important distinction compared to other tracking tools you might be using: the aim here is not to collect general behavior data for statistical analysis, but to gather detailed information for each individual user so that you can properly target user content based on this information.

The following guide will walk you through the steps needed to start tracking user web interaction.

1. Generate an API Token

An API token is needed to identify your site when sending tracking data to Carma. You can generate or view your API token here (link to Tracking Token admin in Carma GUI).

2. Add the Script Tag

The first integration step on your site is to include the tracking script. The script needs to be included on every page where you want to collect tracking information.

You will need two account specific configuration parameters: Your API token and your Carma server id.

<script

 id="carma-tracking"

 type="text/javascript"

 data-server="[Your Carma server id]"

 data-url="//jp52d3joej.execute-api.eu-west-1.amazonaws.com/prod/t"

 data-token="[Your API Token]"

 src="//d3mi6d1ao3fzsg.cloudfront.net/carma-scripts/tracking.min.js">

</script>

The script can be configured to output debug information to the javascript console, which can be useful in the setup phase for trouble-shooting:

<script

 id="carma-tracking"

 type="text/javascript"

 data-server="[Your Carma server id]"

 data-url="//jp52d3joej.execute-api.eu-west-1.amazonaws.com/prod/t"

 data-token="[Your API Token]"

 data-debug="true"

 src="//d3mi6d1ao3fzsg.cloudfront.net/tracking.min.js">

</script>


3. Identify the User

Before tracking information can be registered, the user needs to be identified. For users landing on your site using links configured with Carma ROI tracking this is handled automatically for you by the script. For all other users you will explicitly need to tell the script who the current user is:

<script type="text/javascript">

 carma.tracking.identify("some.user@example.com");

</script>

The identity of the user needs to be the same identifier you are using to uniquely identify your users in Carma. This is often the email address of the user, but depending on your imports to Carma it may be your internal unique identifier of users.

4. Track Behavior

You’re now all set to start tracking user behavior. Information is tracked on a per-action basis. Each tracking event has an action and (optionally) additional information about the event.

Examples:

<script type="text/javascript">

 carma.tracking.track("browsed-category", {

   category: "clothing"

 });

</script>

 

<script type="text/javascript">

 carma.tracking.track("visited-page", {

   page: "index.html"

 });

</script>

The event will automatically be timestamped, enabling you to target content based on when actions have happened, e.g. “target users that browsed category ‘clothing’ during the past two weeks”.

You can also track an action without supplying any specific event details:

<script type="text/javascript">

 carma.tracking.track("visited-page");

</script>

You can track any data you want, but note that the data you collect should be information useful for targeting user content. This means that it will never be a good idea to collect information that is unique for each individual user. E.g. the following would not be a suitable tracking call:

 

<script type="text/javascript">

 carma.tracking.track("visited-page", {

   page: "index.html?sessionId=abc123"

 });

</script>

 

In the above example, the ‘page’ attribute will be unique for each individual user, meaning it will be useless for targeting user content. The same applies to the following call:

 

<script type="text/javascript">

 carma.tracking.track("purchased-item", {

   sku: "abc123",

   category: "clothing",

   orderId: "someUniqueOrderId"

 });

</script>

 

Since the orderId will be unique for each individual call, it will never be useful for targeting user content and should be excluded from the call.