AMP Configuration Variables

Available Chartbeat configurations to be passed into your AMP implementation code.

Introduction

The page property metadata (sections, authors, path, title, and content type) configured to send from your AMP pages should match exactly the data we receive from those same pages on your non-AMP website via our standard JavaScript tag, and stay consistent across all of your other Chartbeat tracked platforms. This is important to ensure accurate page-level engagement tracking in your team's Chartbeat dashboards and audience reports.

Required AMP variables

These variables must be set in your snippet for data to appear in your dashboards.

Field Name

Description

Example Input

uid

A five-digit numerical value associated with your Chartbeat account.

12345

domain

This value should be set to the site id of your website as it appears in your Chartbeat account homepage. This is usually the root domain without http or 'www.' prepended.

site.com

For more information on setting the UID and domain variables, see our customize tracking settings article within our integration guide for non-AMP sites.

Field Name

Description

Example Input

sections

Accepts a comma separated list of values for the page's section(s).

sports,news

authors

Accepts a comma separated list of values for the page's author(s).

John Doe

Tip: Chartbeat uses the "|" character for a splitting process when organizing section and author values, so it is recommend to avoid this character when defining these variables.

Example usage:

<amp-analytics type="chartbeat">
    <script type="application/json">
        {
            "vars": {
                "uid": "12345",
                "domain": "yoursite.com",
                "sections": "News",
                "authors": "John Doe"
            }
        }
    </script>
</amp-analytics>

These variables accept one or multiple string values parsed by comma, so the examples directly above and below would both be acceptable formats.

<amp-analytics type="chartbeat">
    <script type="application/json">
        {
            "vars": {
                "uid": "12345",
                "domain": "yoursite.com",
                "sections": "News,Sports",
                "authors": "John Doe,Jane Doe"
            }
        }
    </script>
</amp-analytics>

Additional AMP variables

Field Name

Description

Example Input

canonicalPath

By default, our tracker collects the page path from the rel="canonical" <link> element in your AMP HTML. If you are unable or prefer to not use the canonical link set in your site's AMP HTML, you may override this default setting. We highly recommend that you use a real path used to navigate to this page.

site.com/path

title

By default, our tracker collects page titles from the <title> tag in your AMP HTML. You can use this variable to override this setting by assigning custom page titles in your Chartbeat for AMP code.

Article Title

contentType

For customers making use of our Advanced Queries tool, this variable accepts a single string value to supplement your Chartbeat historical data with additional information about the type of content a given page falls under, like 'gallery page', 'standalone video page', etc.

gallery page

sponsorName

For customers making use of our Advanced Queries tool, this variable accepts a single string value to supplement your Chartbeat historical data with additional information about your sponsored content (advertorial) campaign name IDs, such as 'Mercedes', 'Mastercard-Jun2020', 'Netflix-Q1-2021-CID123', etc.

Mercedes

Example usage:

<amp-analytics type="chartbeat">
    <script type="application/json">
        {
            "vars": {
                "uid": "12345",
                "domain": "yoursite.com",
                "sections": "News",
                "authors": "John Doe",
                "canonicalPath": "yoursite.com/article-xyz.html",
                "title": "My Article Title",
                "contentType": "article page"
            }
        }
    </script>
</amp-analytics>

IP Truncation

For clients in the EU, use the following <amp-analytics> configuration for Chartbeat to override the host parameter and point traffic to our proxy layer that de-identifies IP addresses within the EU:

<amp-analytics type="chartbeat">
    <script type="application/json">
        {
            “requests”: {“host”: “https://pong.chartbeat.net”},
                "vars": {
                "uid": "12345",
                "domain": "yoursite.com",
                "sections": "section 1,section 2", 
                "authors": "John Doe"
            }
        }
    </script>
</amp-analytics>

Next steps

If your team uses Google Tag Manager for your AMP pages, you have the option to use our pre-built Chartbeat for AMP GTM tag template instead of adding our code directly to your AMP HTML. If you do not use Google Tag Manager, you can skip ahead to our integration QA steps article.

Last updated