Configuration Variables
Configuration variables are set on the _sf_async_config
object, and should be set between the CONFIGURATION START
and CONFIGURATION END comments in the code.
path
Many sites use query parameters for various tracking purposes,
such as seeing if people came from an email newsletter. To
override the path that is reported to Chartbeat, one can set
the
path variable. This could be used in the case
where query parameters are used for other tracking purposes,
so the same article could be accessed using any of these URLs:
http://domain.com/some/pathhttp://domain.com/some/path?_xrf=google.comhttp://domain.com/some/path?_xrf=yahoo.com
Chartbeat uses the raw path, if not specified otherwise. This means
that the same article will show up as three different "pages" in the
Chartbeat dashboard. To "merge" these into one page in Chartbeat, one
can use the path variable and set:
_sf_async_config.path = "/some/path";
The path must start with "/" (forward slash). It is also highly recommended that you use a real path that can be used to browse to this page; some parts of Chartbeat's systems depend on it. The easiest way to get it right is to just use the useCanonical variable instead of setting the path explicitly.
The value should naturally be generated by your CMS, so the same piece
of code can be used in all page templates generically, or one could
set it to window.location.pathname if applicable.
Note: We highly recommend spending some time making sure the paths are cleaned, as it increase the usefulness of Chartbeat a great deal.
title
The title used for a page in Chartbeat can be overriden by setting the
title variable. For example, this is useful in the case where all
documents have a common prefix, like Springfield News: Krusty is
back. Here one can set the title like this:
_sf_async_config.title = "Krusty is back";
domain
This is the domain (without www.) that Chartbeat is installed on.
For handling subdomains, please see Troubleshooting.
useCanonical
If your site defines <link rel='canonical'
.../>, you can set this value to true to
make Chartbeat use the canonical path instead of the
actual URL:
_sf_async_config.useCanonical = true;
This is a good way to ensure consistent and clean URLs across
tracking tools. See also the path
variable. Google have a good introduction
to canonical
links here.
Note: Off-site canonical links, i.e. links pointing to other domains than the page is on, is not supported at the moment.
sections and authors — (For Chartbeat Publishing only)
For Chartbeat Publishing only, you can filter your
content by which section it is in, or who is the author. To be able to
do this the sections and authors variables
need to be set properly.
So if a page is written by Bob Johnson
in the section US Politics, you would set:
_sf_async_config.sections = "US Politics";
_sf_async_config.authors = "Bob Johnson";
A page can both be in multiple sections and/or have multiple authors, so each variable takes a comma separated list of values. So if a page is co-written by Megan Summers and Kevin Smith in the sections Fashion and Fashion News:
_sf_async_config.sections = "Fashion,Fashion News";
_sf_async_config.authors = "Megan Summers,Kevin Smith";
The sections variable does not need to reflect
real sections on the site, but should be thought of as
groupings of pages that can be filtered on.
noCookies
Customers who are subject to the EU e-Privacy Directive can set this variable to prevent Chartbeat from using cookies.
_sf_async_config.noCookies = true;
Note: By using Chartbeat without cookies, you will be unable to see if a user is new or returning.