Skip to content

Tracking SmartNews Content

Parse.ly supports tracking web, AMP, and native content within the SmartNews app. Because SmartNews offers publishers several options for serving their content, the specific steps to integrate Parse.ly tracking will depend on the method chosen.

If your SmartNews headlines link to a web view, no additional integration is necessary, because events will automatically be tracked by your existing Parse.ly website and/or AMP integration. These events will appear in the Parse.ly dashboard with smartnews.com as the referrer.

However, if you provide content to SmartNews via a SmartFormat feed, that content will be natively hosted in the app, and requires adding an additional analytics tag to each <item> (RSS) or <element> (Atom) tag in your feed.

Adding Parse.ly Tracking to SmartFormat Feeds

(The following instructions are for version 2.1 of the SmartFormat specification.)

The <snf:analytics> tag for Parse.ly tracking should look like this (replacing ###### with your Parse.ly site id, e.g. mysite.com, and replacing XXXXXX with the same url specified in the <link> sibling tag):

<snf:analytics><![CDATA[
    <script>
        PARSELY = {
            autotrack: false,
            onload: function() {
                PARSELY.beacon.trackPageView({
                    url: 'XXXXXX',
                    urlref: 'http://www.smartnews.com/'
                });
            }
        }
    </script>
    <script id="parsely-cfg" src="//cdn.parsely.com/keys/######/p.js"></script>
]]>
</snf:analytics>

These tips from the SmartFormat documentation are worth repeating:

  • Be careful with double-escaping when using CDATA (make sure to use <script>, not &lt;script&gt;, for example).
  • If an article is redirected, use the redirected, canonical URL.

Note

Each <item> or <entry> tag can only contain a single <snf:analytics> tag. To track the same item in both Parse.ly and Google Analytics, the code for both should be placed in the same <snf:analytics> tag (see samples below).

Sample (RSS 2.0)

(In this sample, the Parse.ly site ID is example.com.)

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns_content="http://purl.org/rss/1.0/modules/content/" xmlns_dc="http://purl.org/dc/elements/1.1/" xmlns_media="http://search.yahoo.com/mrss/" xmlns_snf="http://www.smartnews.be/snf">
 <channel>
  <title>The Smart Times</title>
  <link>http://times.smartnews.com/</link>
  <description>News for all</description>
  <pubDate>Wed, 01 Oct 2014 06:00:00 GMT</pubDate>
  <language>en</language>
  <copyright>SmartNews, Inc.</copyright>
  <ttl>15</ttl>
  <snf:logo><url>http://times.smartnews.co.jp/snlogo.png</url></snf:logo>
  <image>
    ...
  </image>
  <item>
    <title>SmartNews Launches</title>
    <link>http://times.smartnews.com/2014/10/01/smartnews-launches</link>
    <guid>http://times.smartnews.com/2014/10/01/smartnews-launches</guid>
    <description>
      ...
    </description>
    <pubDate>Wed, 01 Oct 2014 06:00:00 GMT</pubDate>
    <content:encoded>
      ...
    </content:encoded>
    <category>mobile,news,app</category>
    <dc:creator>Rich Jaroslovsky</dc:creator>
    <dc:language>en</dc:language>
    <media:thumbnail url="http://times.smartnews.com/2014/10/01/smartnews.png" />
    <snf:advertisement>
    <snf:sponsoredLink link="http://times.smartnews.com/sponsored/article1.html" thumbnail="http://times.smartnews.com/sponsored/image1.jpg" title="桜丘に新スイーツ店が誕生!" advertiser="桜丘スイーツ"/>
    <snf:sponsoredLink link="http://times.smartnews.com/sponsored/article2.html" thumbnail="http://times.smartnews.com/sponsored/image2.jpg" title="sponsored link 2" advertiser="Example Company"/>
    <snf:adcontent>
      ...
    </snf:adcontent>
    </snf:advertisement>
    <snf:analytics><![CDATA[
      <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-xxx-2', 'examplecom');
      ga('require', 'displayfeatures');
      ga('set', 'referrer', 'http://www.smartnews.com/');
      ga('send', 'pageview', '/260984/upsee/');
      </script>

      <script>
        PARSELY = {
          autotrack: false,
          onload: function() {
            PARSELY.beacon.trackPageView({
              url: 'http://times.smartnews.com/2014/10/01/smartnews-launches',
              urlref: 'http://www.smartnews.com/'
            });
          }
        }
      </script>
      <script id="parsely-cfg" src="//cdn.parsely.com/keys/#######/p.js"></script>
    ]]>
    </snf:analytics>
  </item>
  <item>
    ...
  </item>
  <item>
    ...
  </item>
</channel>
</rss>

Sample (Atom)

(In this sample, the Parse.ly site ID is example.com.)

<?xml version="1.0" encoding="utf-8"?>
<feed xml_lang="en" xmlns_dc="http://purl.org/dc/elements/1.1/" xmlns_media="http://search.yahoo.com/mrss/" xmlns_snf="http://www.smartnews.be/snf">
 <title>The Smart Times</title>
 <link type="text/html" href="http://times.smartnews.co.jp/" rel="alternate"/>
 <subtitle>News for all</subtitle>
 <updated>2014-05-16T06:00:00+0000</updated>
 <rights>(c) SmartNews, Inc.</rights>
 <logo>http://times.smartnews.com/logo.png</logo>
 <snf:logo><url>http://times.smartnews.co.jp/snlogo.png</url></snf:logo>
 <entry>
  <title>SmartNews Launches</title>
  <link type="text/html" href="http://times.smartnews.co.jp/2014/06/16/sakuragaoka" rel="alternate"/>
  <id>http://times.smartnews.com/2014/10/01/smartnews-launches</id>
  <updated>2014-05-16T06:00:00+0000</updated>
  <content>
    ...
  </content>
  <category>mobile,news,app</category>
  <author>Rich Jaroslovsky</author>
  <dc:language>en</dc:language>
  <media:thumbnail url="http://times.smartnews.com/2014/10/01/smartnews-launches/img.png" />
  <snf:advertisement>
   <snf:adcontent>
    ...
   </snf:adcontent>
  </snf:advertisement>
  <snf:analytics><![CDATA[
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-xxx-2', 'examplecom');
    ga('require', 'displayfeatures');
    ga('set', 'referrer', 'http://www.smartnews.com/');
    ga('send', 'pageview', '/260984/upsee/');
    </script>

    <script>
      PARSELY = {
        autotrack: false,
        onload: function() {
          PARSELY.beacon.trackPageView({
            url: 'http://times.smartnews.co.jp/2014/06/16/sakuragaoka',
            urlref: 'http://www.smartnews.com/'
          });
        }
      }
    </script>
    <script id="parsely-cfg" src="//cdn.parsely.com/keys/######/p.js"></script>
    ]]>
    </snf:analytics>
 </entry>
 <entry>
  ...
 </entry>
</feed>

Limitations

Tracking video plays from SmartFormat feeds is not currently supported.

Last updated: October 17, 2024