User Subscriber Status

This article details the steps to implement your site's user subscriber status data into Chartbeat by adding a few lines to our standard tracking tag.

Tracking users' subscriber status

If you allow users to login to your site, or provide subscriber-only content, add the below configuration to your Chartbeat tag to enable traffic data segmentation by user-type in our tools. First, you'll need to declare a global _cbq variable with the following code:

var _cbq = window._cbq = (window._cbq || []);

Then, based on what type of user is currently browsing your site, push the following array elements that constitute a key-value pair to the _cbq array:

_cbq.push(['_acct', 'user_type']);

Always push _acct as the first element in the array, with that representing the key of a key-value pair. The second element in the array represents the value of the key-value pair. For the user_type value, please use one of the three standardized values below:

Subscriber Status

user_type Value

Guest

anon

Registered

lgdin

Subscriber

paid

Generally, it's best practice to declare _cbq and perform your _cbq.push() right after your _sf_async_config setup. For example, if you wanted to push a user type of paid, your implementation might look like this (see lines 11 & 12):

<script type='text/javascript'>
    (function() {
        var _sf_async_config = window._sf_async_config = (window._sf_async_config || {});
        /** CONFIGURATION START **/
        _sf_async_config.uid = #####; //CHANGE THIS
        _sf_async_config.domain = 'domain.com'; //CHANGE THIS
        _sf_async_config.useCanonical = true;
        _sf_async_config.useCanonicalDomain = true;
        _sf_async_config.sections = ''; //CHANGE THIS TO YOUR SECTION NAME(s)
        _sf_async_config.authors = ''; //CHANGE THIS TO YOUR AUTHOR NAME(s)
        var _cbq = window._cbq = (window._cbq || []);
        _cbq.push(['_acct', 'paid']);
        /** CONFIGURATION END **/
        function loadChartbeat() {
            var e = document.createElement('script');
            var n = document.getElementsByTagName('script')[0];
            e.type = 'text/javascript';
            e.async = true;
            e.src = '//static.chartbeat.com/js/chartbeat.js';
            n.parentNode.insertBefore(e, n);
        }
        loadChartbeat();
     })();
</script>

It's up to your team to create the custom logic to automatically pass in one of our three user-type values each time our tag is loaded, based on the current user's status in your site's user tracking mechanism.

Tip: If your user subscriber status data only becomes available later in the page load, you can load the Chartbeat tag lower in the page HTML instead of placing our tag in the page's header. However, if your site will utilize our Headline Testing integration where some of our code is required to load before the closing <head> tag, we suggest using our two snippet solution detailed in the next page of this guide.

Next steps

You've learned about our JavaScript tag and tracking script, how to customize your pageview tracking settings with our configuration variables, tracking virtual pageviews, and user subscriber status. Now review our options for alternative integrations of our website tracking code in the next page of this guide to see if any of these options apply to your setup.

Last updated