Getting started with 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.

Javascript 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: "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>

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.