Track webviews in your aplication as app traffic

Marfeel supports different page technologies like Web or AMP that allow users to slice and dice data based on their distribution technology.

Each Marfeel SDK automatically encodes a value according to this table:

Id Page Technology
0 Web
1 AMP
2 FBIA
3 iOS App
4 Android App
5 Flowcards
6 Pressreader
7 App
8 Apple News

Specify the pageType

There are cases where the developer might want to change the pageType default value set by the AMP or JS SDK to a different value. Both the JS and AMP SDKs allow you to override its values.

Set pageType via JS SDK

If you bundle your web version as a native application in a Webview you can identify a different page technology on the Marfeel tracker initialization:

{pageType:"app"}

A complete code snippet would look like:

var mrfTech = 'web';
if(is_app){ //use your own logic to know if the page is loading in your inapp webview
   mrfTech='app';
}

function e(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=document.createElement("script");c.src=e,t?c.type="module":(c.async=!0,c.type="text/javascript",c.setAttribute("nomodule",""));var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(c,n)}function t(t,c,n){var a,o,r;null!==(a=t.marfeel)&&void 0!==a||(t.marfeel={}),null!==(o=(r=t.marfeel).cmd)&&void 0!==o||(r.cmd=[]),t.marfeel.config=n,t.marfeel.config.accountId=c;var i="https://sdk.mrf.io/statics";e("".concat(i,"/marfeel-sdk.js?id=").concat(c),!0),e("".concat(i,"/marfeel-sdk.es5.js?id=").concat(c),!1)}!function(e,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t(e,c,n)}(window,
   /*accountId*/,
   {pageType:mrfTech} /*config*/
);

Set pageType on AMP

On AMP you can override the default pageType adding a var directly on the Marfeel snippet:

<amp-analytics config="https://events.newsroom.bi/amp.v1.json" data-credentials="include">
  <script type="application/json" >
    {
      "vars" : {
        "accountId": "000", //USE YOUR PERSONAL ACCOUNT ID
      },
      "extraUrlParams": {
         "pageType": 3
      }
    }
  </script>
</amp-analytics>
1 Like