Standard Implementation

 

Standard implementation is the most common type of implementation, and is loosely defined as the method you would use on pages where the content changes when the URL changes. Install the code below on your article page template or any content page that you want tracked. The parameters (i.e. pid, title, url, etc.) should be passed up by the CMS in the format mentioned below.

We strongly recommend that you check out our best practices before placing the implementation code on your site, and using our Chrome extension to debug it after the code is placed.

Got a mobile site? For complete coverage, be sure to add the SimpleReach code to your mobile templates as well.

Please note if you have or are planning to attach another implementation to the same account, for example, a mobile app implementation, all content fields (marked here with a *) for a given piece of content must match across all implementations. See Multiple Implementations in our Implementation Best Practices for more information.

Add the following code to your site with your chosen values in place of the values preceded by a $(dollar) sign: 

(Note: The dollar signs in the code example below are not part of the syntax, they are simply a part of the placeholder values. Please do not include the dollar signs in your code.)

__reach_config = {
  pid: '$pid',
  title: '$title',
  url: '$canonical_url',
  date: '$publication_date',
  authors: ['$author'],
  channels: ['$chan1'],
  tags: ['$tag1','$tag2'],
  article_id: '$article1',
  ignore_errors: false
};
(function(){
  var s = document.createElement('script');
  s.async = true;
  s.type = 'text/javascript';
  s.src = document.location.protocol + '//d8rk54i4mohrb.cloudfront.net/js/reach.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
})();

Required Parameters

PID (required):

This is the SimpleReach-assigned Publisher ID (PID) that you should have received by email. Your PID is a 24-character alphanumeric string that looks similar to: 4fc608fea782f333ea0000fb. If you don't have your PID yet, send us an email and we'll make sure you have one.

In your final implementation code, your PID will look something like this:

pid: '4fc608fea782f333ea0000fb'

If you’d like to use a test PID to check if your code is implemented correctly before pushing it to your entire site, check out our documentation on testing.

URL (required):

We support automatic URL detection if your site headers contain Facebook Open Graph tags (specifically 'og:url') or canonical URL meta tags in this format:

<link rel="canonical" href="http://www.website.com/categories/article1.html" />

If your site contains either of these tags in its header, you do not need to include the 'url' field—it will populate automatically.

There are many reasons why you'd want to include the rel=canonical meta tag in your headers. Click here to read more about it!

If your site headers do not contain these tags, you will need to include the canonical URL in this field, which is the canonical or permanent URL of the content. This is the URL that a user would enter in a browser to visit the page directly and should not include the protocol unless this changes the content being rendered. Trailing slashes should also be consistent. Be sure that the URL is stripped of any query parameters that may be included. So, if a user navigates to:

http://www.website.com/articles/interesting-news?thing=true

That 'url' field should populate with:

http://www.website.com/articles/interesting-news

Since this is how we identify unique pieces of content and create dashboards, it's important that the URL in the 'url' field for a given piece of content always be exactly the same, regardless of any query parameters that may be appended to the URL that the user used to arrive there. Example:

url: 'http://blog.simplereach.com/is-your-content-missing-its-readers/' 

Date (required)*:

Content publish date in UTC or any ISO8601 date.

date: '2014-10-30 15:00:06'

The date value must be JavaScript parsable. Once the implementation code is on the page, one way of checking this is to open up the JavaScript console while on the page and enter the following:

new Date(Date.parse(__reach_config.date));

If the console returns the content piece's publication date, then the date is parsable by JavaScript.

Title (required)*:

The title of the content piece.

title: 'How To Use StumbleUpon As A Secret Weapon'

DOMAIN (CONDITIONALLY REQUIRED):

The full domain of the site. If your site uses custom domains, this field should be set to allow us to whitelist the custom domains and aggregate data under your account. For example, if you have a custom domain of 'custom.simplereach.com', you should pass us 'custom.simplereach.com' for this field. This should not include the protocol (http).

domain: 'custom.simplereach.com'

Authors (recommended)*:

An array containing the content piece's author or authors.

Example of single author:

authors: ['Alexis Krantz']

Example of multiple authors:

authors: ['Alexis Krantz', 'Joe Smith', 'Kent Brockman']

Channels (recommended)*:

An array that includes the content piece's channel or channels. Channels typically represent sub-sites of your main site, and are represented as “categories” in our tool.

channels: ['health', 'beauty']

Tags (recommended)*:

An array containing the content piece's tag or tags, such as those that might appear at the bottom of the content piece to describe its content in more detail.

tags: ['content analytics', 'content marketing', 'publishers']

Be sure the strings entered in these fields are typed exactly as they should appear. Do not escape or HTML/URL encode the strings. Be sure that there are no JavaScript errors.

Optional Parameters

Most implementations will not require these, but if you think you need them, please feel free to email us and ask.

ARTICLE_ID (OPTIONAL): 

Prior to implementing article_id for your content, we highly recommend reading our Article Metrics section. 

The article_id parameter is used (optionally) to group and identify several pieces of content on different URLs as one “Article” in our Dashboard.  These content items, once grouped, will enable an additional “Article” level set of metrics that combines (or “rolls-up”) the data from the individual content items.

The article_id field can be set as a string or integer of your choice.  For example, when using a string, the article_id setting would be similar to:

article_id: ‘AB Test 5388SD7000001’

And alternatively, if using an integer, the configuration would be set as:

article_id: 538007000001

If you do not add in the article_id field to the __reach_config, it will default to the content’s content_id in our system. 

IGNORE_ERRORS (OPTIONAL):

Default value is false. If this is set to true, JavaScript error messages will not be sent to the console.

USER_ID (OPTIONAL):

Optional parameter to provide a unique user id to track unique users across browsers and devices. This value can be anything and is usually the ID for the user from the publisher's login. If you do NOT have a method of providing your own unique user ID in this field, please do not include it in the __reach_config object. Each unique user_id is counted as a unique user in our system, so if this is not populated properly, we will not be able to correctly count unique users in our tool. If you do not include the user_id field, we will calculate unique users via our own methods.

If you choose not to employ an optional parameter, be aware of their default values.