My app ads in Facebook tracking for all app installs, how to track app installs only from facebook leads for ANDROID

喜夏-厌秋 提交于 2020-01-30 08:17:07

问题


Facebook ads tracking for all app installs from playstore. I need to track only for App Intalls from facebook ads lead.

Please help. Note: I'm able to see logs in the power editor reports.

Here is the below code:

Inside Launcher Activity

protected void onResume() {
super.onResume();
    try {
        AppEventsLogger logger = AppEventsLogger.newLogger(this);
        AppEventsLogger.activateApp(this, getResources().getString(R.string.app_id));
        logger.logEvent(AppEventsConstants.EVENT_NAME_ACTIVATED_APP);
        Settings.addLoggingBehavior(LoggingBehavior.APP_EVENTS);
    } catch (Exception e) {
         e.printStackTrace();
    }
}

回答1:


Integrate google analytics with your android app, From there you can able to track down the all sources of your app installation (Campaign measurement).

https://developers.google.com/analytics/devguides/collection/android/v2/campaigns

You dont want to use AppEventsLogger to track installation source if your using analytics already.

Just you need to add Campaign measurement concept from analytics so that automatically Google analytics will start tracking the sources of your app.

Include this in your app manifest,

 <service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />

        <receiver
            android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

In the onstart of LaunchActivity of your app

     @Override
        protected void onStart() 
        {
            // TODO Auto-generated method stub
            super.onStart();
                Intent installintent = this.getIntent();
                Uri installuri = installintent.getData();

            if (installuri != null) 
            {
                sendInstallCampaign(installuri);
            }
        }



   private void sendInstallCampaign(Uri  uri)
   {

    if(uri!=null)
    {
        MapBuilder paramMap = new MapBuilder();

        if (uri.getQueryParameter("utm_source") != null) 
        {
            system.out.println("utm_source: "+uri.getQueryParameter("utm_source");

              /* MapBuilder.setCampaignParamsFromUrl parses Google Analytics campaign
              ("UTM") parameters from a string URL into a Map that can be set on
               the Tracker.*/

              paramMap.setCampaignParamsFromUrl(uri.toString());

             /*If no source parameter, set authority to source and medium to
             "referral".*/

        } else if (uri.getAuthority() != null) 
        {
               paramMap.set(Fields.CAMPAIGN_MEDIUM, "referral");
               paramMap.set(Fields.CAMPAIGN_SOURCE, uri.getAuthority());
        }
        MapBuilder.createAppView().setAll(paramMap.build());
    }
}

When you submit your app url to facebook, use this url builder and submit the resultant url

https://developers.google.com/analytics/devguides/collection/android/v2/campaigns#google-play-url-builder




回答2:


Normally, you would set up an ad campaign with a reference to your app in the app store like this:

https://play.google.com/store/apps/details?id=com.foo.app&referrer=utm_source%3Dfacebook%26utm_medium%3Dcpc...

Note the URL encoded UTM key-value pairs.

However, Facebook doesn't allow you to put a raw URL into the ad setup for an App Install campaign. When you enter your app name or the full URL to the app, the FB campaign setup tools will search the Play Store and show you matches. Then you select the app, but it strips off any additional query params from the URL so you're left with a reference like

https://play.google.com/store/apps/details?id=com.foo.app

As a result, there's no referrer query param and so there's also no INSTALL_REFERRER. It's a total miss on FB's part and I was shocked at this when I first discovered it. Instead, you can set up a display ad campaign in FB (where you can enter any URL you want). The downside of this is that the campaign won't be able to optimize itself for app installs (since the conversion event stops at click throughs).



来源:https://stackoverflow.com/questions/25138951/my-app-ads-in-facebook-tracking-for-all-app-installs-how-to-track-app-installs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!