OKO Digital

The ad optimisation people

  • Home
  • Publisher Solutions
    • Website Monetization
    • Header Bidding Max
    • Header Bidding for DFP
    • Ad Exchange for Header Bidding
    • App Monetisation
  • Resources
    • Ad Speed Tester
    • EU User Consent Guide
  • About us
    • OKO & the OKO team
    • Career opportunities
  • Blog
    • Latest blog posts
    • Ad Blocking
    • Ad Exchange (AdX)
    • Ad Optimisation
    • Ad Performance & Page Speed
    • Ad Publishing Landscape
    • AdSense
    • DoubleClick For Publishers (DFP)
    • Google Ad Manager
    • Google Certified Publishing Partners
    • Header Bidding
    • Privacy & GDPR
    • Program Policy
    • Traffic
  • Contact

Traffic . 2nd February 2016

Tracking Facebook in-app browser in Google Analytics

I recently wrote about Facebook’s in-app browser over on StateOfDigital.  In that I encouraged marketers and publishers to stop ignoring what is one of the most popular and under-reported segment of browsers on the web.

Anyone involved in marketing or monetizing a website that gets traffic from Facebook would do well to read this if they are not already familiar with the issues.  In short, apps like Facebook often now open links in their own browser window. This isn’t reported by analytics, might render differently and will make a mess of your advertising revenues and cookie use.

In-app browsers, the hidden issue

The first step to dealing with the issue, as ever, is to measure it.  This is a challenge as  Google Analytics doesn’t properly report on in-app browsers.  Looking at Google Analytics might lead you believe that it is only Safari users who use in-app browsers, which is not the case. In-app browsers (accurately called “web view windows”) run as a child of whatever the user’s primary browser is.  Safari chooses to report this as ‘Safari (in-app)’ where as other browsers don’t differentiate.  A Chrome user viewing your website in-app, for instance, will simply report as using Chrome, even though their experience might be quite different to if they were using the full browser.

in-app browsershare

Throwing light on the issue

As in-app browsers can have a big impact on ad revenue, this is information that I want to be able to access when working with partners on website monetisation.   The first step for me is to plug this gap in Google Analytics.  I do this using Custom Dimensions.

Adding a Custom Dimension for in-app browsers

Custom Dimensions are a handy feature of Analytics that are perfect for jobs like this.  Adding a custom dimension of in-app browsers will allow us to start tagging up users of any that we are interested in tracking. Here is how:

In Google Analytics

  1. Switch to the property where the data will be saved
  2. Click Admin, then select Custom Definitions, then Custom Dimensions
  3. Create a new custom dimension as shown here

facebook-inapp-custom-dimension

This gives you a way to track the dimension. Take a note of what Dimension number is used when you create this.  We now just need to pass the value into Facebook.

On-page changes

In order to pass the value into Google Analytics we need to read the user-agent string and set the custom dimension.  This just needs a small snippet added to the Analytics tag:

Assuming you are using GPT tags simply add the following line just before ga(‘send’, ‘pageview’);

var ua = navigator.userAgent || navigator.vendor || window.opera;
ga('set', 'dimension1',(ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1) ? 'Facebook' : 'None');

Note, if the in-app dimension isn’t the first that you have created then you may need to change dimension1 to match the dimension number created in analytics earlier.

How to read this

This method allows you to add dimension to show in-app browser use to most reports.   For instance, here is a breakdown for traffic referred from Facebook to a test link that I shared.

in-app browser from facebook referrals

Having this data available as a dimension allows you to apply it to many report types. You could, for instance, compare bounce rates, visitor loyalty or AdSense/Adx revenue performance.

Taking the idea further

The script snippet provided only detect’s Facebook’s in-app browser, but the logic can be applied to the webview windows opened by other mobile apps.  You simply need to find the unique strings reported in their user-agents.

For those involved in ad-serving the same technique can be used to target in-app browsers in DFP, allowing you to measure ad performance and send more targeted impressions to those users. Keep an eye on the blog for exactly how to do that in my next article.

 

Traffic . Tips

Could the ads on your site be earning more?

Learn more about how OKO help publishers earn more from their ads.

Learn More

Mat Bennett

Comments

  1. Cam Beck says

    27th April 2016 at 4:13 pm

    How would you implement this through GTM?

    Reply
    • Mat Bennett says

      17th June 2016 at 11:20 am

      This is a very good question. I’ve not done it that way, but I might now. Thanks for the idea! If I do then I’ll post the solution back to the blog.

      Reply
      • Josephine Søgaard Andersen says

        1st September 2016 at 11:52 am

        I’d love to know this as well! :)

        Reply
  2. David Richarz says

    13th June 2016 at 3:54 pm

    How do you ensure that ga(‘set’, ‘dimension1’,(ua.indexOf(“FBAN”) > -1) || (ua.indexOf(“FBAV”) > -1) ? ‘Facebook’ : ‘None’); is only set when someone follows a link to your website via Facebook’s web-view?

    Reply
    • Mat Bennett says

      15th June 2016 at 3:10 pm

      We set the value on every visit, but the value we are setting is whether the user-agent includes the string “FBAN” or not. This is a fairly reliable footprint for the facebook inapp browser.

      Reply
      • David Richarz says

        16th June 2016 at 4:56 pm

        Thanks for the reply, Mat! I thought there might be a way to set this dimension only on Visits that really originate from FB’s Webview and use a default ‘None’ value for everything else from GA internally. I have some rather big sites that get frequently visited from Google or via direct and more, where I’d like to use as little code as possible, since there is already a lot of Objects set for GA.

        Reply
        • Mat Bennett says

          17th June 2016 at 11:21 am

          Should be pretty easy just to wrap the whole thing in an if statement that checks for that same string.

          Reply
  3. Hema says

    3rd April 2017 at 12:08 pm

    Informative!! Thanks a lot Mr. Mat Bennett!!

    I was in confusion since last 8 months regarding the huge difference in Facebook insights and GA numbers. For now, my research end-up with this article and try the same on my website. Thank again!!

    Reply
  4. Shehbaz says

    28th April 2018 at 11:57 am

    Hi,

    My total number of sessions from facebook before applying the secondary dimension for a particular date was 164. Once I add a secondary dimension of Facebook In app, it only shows 11 sessions. Facebook-None=7 and Facebook-Facebook=4.

    Am I doing anything wrong or is there a different way to read this report?

    Please help!

    Reply
  5. Amy Smith says

    14th September 2018 at 11:41 pm

    Hello!

    How do you ensure that your event setup works properly in in-app browsers? Have you ever seen issues where one event will over-fire due to being used in an in-app browser?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Topics

  • Ad Blocking
  • Ad Exchange (AdX)
  • Ad Optimisation
  • Ad Performance & Page Speed
  • Ad Publishing Landscape
  • AdSense
  • DoubleClick For Publishers (DFP)
  • Google Ad Manager
  • Header Bidding
  • Privacy & GDPR
  • Program Policy
  • Traffic

Essential publisher news

Get our free monthly publisher bulletin featuring essential news, features and tips for publishers. Sign up for free. Unsubscribe at any time.
  • This field is for validation purposes and should be left unchanged.

The Cake Shed, Manor Farm, Manor Road, Hayling Island, Hampshire, PO11 0QW

023 9246 0000

OKO Facebook
OKO Linkedin
OKO Twitter
OKO Instagram
Google Certified Publisher Partner Logo

OKO is a registered trademark and trading style of OKO Digital Limited. Registered in England company number 03867231. © OKO Digital Limited 1996-2018. All Rights Reserved.

  • Privacy Policy
  • Cookie Policy