<head>. In this case, we recommend splitting our code into the following two snippets with the first snippet being implemented directly in your source code, after canonical URLs are defined in your header HTML.
The above code needs to load early in the
<head> after canonical URLs are loaded because it is responsible for altering the headline text in your homepage template to display test variant headlines to your visitors.
The below code includes the rest of our tracking snippet, and can be loaded via a custom tag near the top of the
<body> , or whenever your data layer is available with the necessary section & author or user subscriber status data.
<head>. For these sites, we also recommend implementing the above header snippet (containing our Headline Testing JS) separately in the
<head> after canonical URLs are loaded. The rest of our code can be called later in the page load sequence, whenever your preferred page data is available.
If your site will not make use of your Headline Testing feature, our full snippet can be called later in the page load sequence, skipping the steps above to split the snippet in two. Note that calling our tracking script later in the page load sequence may cause missed visitor pageviews which start and end prior to page load completion.
As a first stop resource for understanding how Chartbeat tracking complies with GDPR regulations, check out our Data Protection resources page.
Chartbeat does not set third-party cookies. We also do not take any steps to identify specific visitors (for example, we do not do browser fingerprinting or collect device IDs). Chartbeat was designed with privacy in mind, and is a first-party analytics platform. This means that publishers who use our service can set first-party cookies on their sites using Chartbeat code, or they can run in cookie-less mode.
_sf_async_config.noCookies = true;
Instead of running our tracking in cookie-less mode across your site, we recommend that teams consider using the below popular workaround implementations to ensure optimal functionality of your Chartbeat tools. If your site uses a cookie consent banner which allows users to provide explicit consent by clicking a button to agree, or inexplicit consent by clicking into an additional page of your site, we recommend using one of these two options:
Hook into your site's unique logic to recognize new un-cookied users to your site, and add conditional logic to your analytics tags to prevent our code from loading for these users until they (A) click the button in your banner to provide consent, or (B) provide consent by clicking into an additional page of your site to continue using it. Note that this will cause missed pageviews for users who do not provide consent on their initial page visit.
Similar to the implementation above, but instead of preventing the Chartbeat snippet from loading for users that have not provided consent yet, add conditional logic that sets our
noCookies configuration variable to true for these pageviews only. As soon as the visitor provides consent by viewing an additional page of your site, your custom code should recognize the cookied user and no longer set the
noCookies variable in your Chartbeat snippet.
Some of our partner sites that have been with us for a while are using our previous snippet for basic tracking functionality, included below. The primary differences between our previous recommended code and our current snippet are twofold:
This snippet includes code that delays chartbeat.js from being called until the page has finished loading, on the
document.ready event. Our new snippet loads chartbeat.js immediately, asynchronously.
We previously recommended loading our snippet near the bottom of the
<body>. We've since adjusted our default implementation to load our script early in the
<head> to ensure we capture brief user pageviews which end prior to page load completion.
For partners still using this older version of our tracking code, it will still work but we recommend updating to our latest implementation specs for the reasons detailed above.
Having reviewed all of the previous articles in this guide, identifying the configuration options and tracking methods that best fit your site, you're now ready to add our snippet to your website using our integration QA article (up next) to check your work for completeness.