Getting started with Brevo Tracker

Brevo tracker is meant for tracking all the events related to your users occurring outside of Brevo. This can help you identify when email recipients open an email or click a link on your website β€” when new or existing contacts submit a form or make an order from your mobile app.

More globally, Brevo tracker provides you several ways to help you get to know your customers and to see how they interact with your various marketing initiatives.

The Automation app can help you automate your lead scoring or the way contacts flow through your customer journeys based on the events triggered by Brevo tracker.

πŸ“˜

If you enable the automation app on your Brevo account, some of the events will be automatically tracked for you like:

  • When the email recipient opens an email.
  • Clicks and interactions in email.
  • Adding a contact to a list.

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>