Thursday, December 17, 2015

Selecting native animation view

When creating an Android native (non-OpenGL) animation on a view, there are few options:
  • SurfaceView
  • TextureView (Android 4.0+)
  • View
While in Android 2.x SurfaceView was the best way, things changed. I'll skip to the bottom line: to my opinion as of Android 6.0 the best was is to override View. The reason is that both SurfaceView & TextureView do not support Android's hardware acceleration.

Hardware accelerated View is over x4 faster than SurfaceView & TextureView.

Sunday, June 7, 2015

AdMob interstial adapter for Appnext

I needed intergration Appnext into AdMob mediation bt there was not AdMob adapter, so I wrote one. Please note this adapter uses Appnext's Activities & not in-activity popups.


package com.appnext.appnextsdk;

import android.content.Context;
import android.os.Bundle;

import com.google.android.gms.ads.mediation.MediationAdRequest;
import com.google.android.gms.ads.mediation.customevent.CustomEventInterstitial;
import com.google.android.gms.ads.mediation.customevent.CustomEventInterstitialListener;

public class AppnextAdMobAdapter implements CustomEventInterstitial {
 private CustomEventInterstitialListener mCustomEventInterstitialListener;
 private String mPlacementId;
 private Context mContext;
 
 @Override
 public void onDestroy() {
 }

 @Override
 public void onPause() {
 }

 @Override
 public void onResume() {
 }

 @Override
 public void requestInterstitialAd(Context context,
            CustomEventInterstitialListener listener,
            String serverParameter,
            MediationAdRequest mediationAdRequest,
            Bundle customEventExtras) {
  mContext = context;
  mPlacementId = serverParameter;
  mCustomEventInterstitialListener = listener;

  if (mCustomEventInterstitialListener != null)
   mCustomEventInterstitialListener.onAdLoaded();
 }

 @Override
 public void showInterstitial() {
  PopupActivity.setAdLoadInterface(new OnAdLoadInterface() {   
   @Override
   public void adLoaded() {
    if (mCustomEventInterstitialListener != null)
     mCustomEventInterstitialListener.onAdLoaded();
   }
  });
  PopupActivity.setNoAdsInterface(new NoAdsInterface() {   
   @Override
   public void noAds() {
    if (mCustomEventInterstitialListener != null)
     mCustomEventInterstitialListener.onAdFailedToLoad(0);
   }
  });
  PopupActivity.setPopupOpenedInterface(new PopupOpenedInterface() {   
   @Override
   public void popupOpened() {
    if (mCustomEventInterstitialListener != null)
     mCustomEventInterstitialListener.onAdOpened();
   }
  });
  PopupActivity.setPopupClickedCallback(new PopupClickedInterface() {
   @Override
   public void popupClicked() {
    if (mCustomEventInterstitialListener != null)
     mCustomEventInterstitialListener.onAdClicked();
   }
  });
  PopupActivity.setPopupClosedCallback(new PopupClosedInterface() {   
   @Override
   public void popupClosed() {
    if (mCustomEventInterstitialListener != null)
     mCustomEventInterstitialListener.onAdClosed();
   }
  });

  Appnext.showPopupInActivity(mContext, mPlacementId, false);
 }
}

Tuesday, April 7, 2015

Detecting mobile app CPI frauds

Most CPI campaign work quite nicely. However, I saw this video which claim major click-frauds on Facebook ads from click-farms in specific countries. I've decided to re-check my last CPI campaign.

How I checked: by country, check the average session duration during the campaign. Filter only countries with average session duration less than 50% of the average.

Finding: At least 2 of the top 10 countries in the campaign clearly had a CPI fraud. The average session duration was less than 50% of the average, the CTR was x2-x4. Next time I'll look for it in real time. I've compared it with the data after the campaign & the session duration went back to normal.

Waste of money.

Bottom line: How I will search for ad frauds, at country level:
  1. Significantly low (or high) session duration
  2. Significantly high ad CTR rate

Sunday, January 11, 2015

Calculating Google Analytics event value variance & standard deviation

Here's I calculated the var & stddev of an event value (X) tracked by Google Analytics:
  1. Add a second event with the value X^2
  2. Calculate the variance using this formula: Var = E(X^2) - [E(X)]^2  (note that Google Analytics already calculates E(X^2) & E(X), which are, in this case the event's average).