Getting started with Brevo Tracker

Brevo tracking is designed to monitor customer-related events occurring outside of Brevo.

Tracking offers multiple methods to help you understand your customers and observe their interactions with your website.

Additionally, you can update your contact list based on interactions on websites where the tracker is installed. You can also create conditional statements in your marketing automation flows, governed by events pushed from the tracker.

📘

What can be tracked?

Depending on your configuration the tracking criteria can vary. In general the options are as follows:

  • You log the event when a user clicks on a link in your website
  • You log whenever a page from your website is visited
  • You log a custom event for which you define its specific attributes and values
  • You identify recurrent visitors in your website. For this ones you can log their email address, IP address and update their contact attributes in Brevo, if needed.

Javascript Implementation

There are two types of tracker implementations Restful implementation and Javascript (JS) implementation but we will be using the JS implementation.

This is the most straight forward implementation if you need to track all the events happening on your website. All you have to do is to set up a short JS snippet on your website and we will start tracking your user along with the page views for you.

If you're using one of our plugins (Wordpress, Prestashop) or Google Tag Manager it's even easier, you don't need to do any development to get the tracking working.

There are two ways to implement Javascript, through the Javascript tracker code and Google Tag Manager. Both methods are explained below.

JS Tracker script

To enable the JS implementation, you can use the tracker script from your Automation menu in your Brevo account.

<script type="text/javascript">
(function() {
    window.sib = {
        equeue: [],
        client_key: "xxx765xaxx12xbxx89xxcxxx"
    };
    /* OPTIONAL: email for identify request*/
    // window.sib.email_id = '[email protected]';
    window.sendinblue = {};
    for (var j = ['track', 'identify', 'trackLink', 'page'], i = 0; i < j.length; i++) {
    (function(k) {
        window.sendinblue[k] = function() {
            var arg = Array.prototype.slice.call(arguments);
            (window.sib[k] || function() {
                    var t = {};
                    t[k] = arg;
                    window.sib.equeue.push(t);
                })(arg[0], arg[1], arg[2], arg[3]);
            };
        })(j[i]);
    }
    var n = document.createElement("script"),
        i = document.getElementsByTagName("script")[0];
    n.type = "text/javascript", n.id = "sendinblue-js", n.async = !0, n.src = "https://sibautomation.com/sa.js?key=" + window.sib.client_key, i.parentNode.insertBefore(n, i), window.sendinblue.page();
})();
</script>

After copying this script, you need to paste it before the tags on every page on which you want to track users activity. If the snippet is added correctly then status will be shown as verified on your Brevo account in the part under the JS tracker script.

Integrating code into website by Google Tag Manager

You can use Google Tag Manager to include the code snippet into the website to track activity. Its more quick and efficient as you don't have to manually include the script. You can see the steps below to include the JS tracker script:

  1. You can login or create an account of Google Tag Manager.
  2. You can create a workspace for your website.
  3. After that you can go to Workspace and go to Tags.
  4. In Tags, you can create a new tag and choose a custom HTML tag.
  5. Copy your JS tracker script and paste it in the space provided.
  6. Save this tag and finally, publish the container.

After performing the pre-requisites, you can implement tracking by running different Javascript functions and code. You can perform actions like identifying visitors, tracking link clicks, tracking page views along with tracking tailored events.

Restful Implementation

Tracker implementation by REST API is used by mobile applications on the server-side. You will have to use email addresses to call every user.

We are going the mention the endpoints for the events tracking in this document using the REST API. Like the Javascript(JS) implementation, the REST API allows you to track the events but JS allows you more functionality like:

  1. The Javascript tracker tracks the page views for you and it is an automated process while in Restful implementation you will have to run the events yourself.
  2. We won't be able to track the users who clicked on your emails.
  3. For Restful implementation, you will have to pass email to the call because this would identify the users.

Authentication for the REST API

The Restful implementation requires an ma-key to authenticate which you can get from your Brevo account. You can find the below script in the Automation menu in your Brevo account under Javascript (JS) Tracker.

<script type="text/javascript">
(function() {
    window.sib = {
        equeue: [],
        client_key: "xx44x0iexxxjlk5xx44jrx8o"
    };
    /* OPTIONAL: email for identify request*/
    // window.sib.email_id = '[email protected]';
    window.sendinblue = {};
    for (var j = ['track', 'identify', 'trackLink', 'page'], i = 0; i < j.length; i++) {
    (function(k) {
        window.sendinblue[k] = function() {
            var arg = Array.prototype.slice.call(arguments);
            (window.sib[k] || function() {
                    var t = {};
                    t[k] = arg;
                    window.sib.equeue.push(t);
                })(arg[0], arg[1], arg[2], arg[3]);
            };
        })(j[i]);
    }
    var n = document.createElement("script"),
        i = document.getElementsByTagName("script")[0];
    n.type = "text/javascript", n.id = "sendinblue-js", n.async = !0, n.src = "https://sibautomation.com/sa.js?key=" + window.sib.client_key, i.parentNode.insertBefore(n, i), window.sendinblue.page();
})();
</script>