facebook-ios-sdk icon indicating copy to clipboard operation
facebook-ios-sdk copied to clipboard

StarTrial event is not sent by FB iOS SDK when a trial is activated (Purchase event is sent instead)

Open maximaleks opened this issue 1 year ago • 16 comments

Checklist before submitting a bug report

Xcode version

14.2

Facebook iOS SDK version

16.0.1

Dependency Manager

CocoaPods

SDK Framework

Core

Goals

I noticed that StartTrial events stopped tracking after FB iOS SDK update from 15 to 16. My FB advertisement companies don't track StarTrial anymore. I want to track the StartTrial event after the user starts a trial but currently, the Purchase event is tracked instead.

Expected results

When an auto-renewable subscription is activated, StartTrial event sends from FB SDK

Actual results

Currently, the Purchase event sends after the trial is activated instead of StartTrial event.

Steps to reproduce

  1. Activate auto-renewable subscription purchase with a trial in the iOS app, for example, $14.99 annually with 3-days of trial
  2. Check what data is being sent from the Facebook SDK https://graph.facebook.com/v16.0/395012578261333/activities

Code samples & details

https://graph.facebook.com/v16.0/395012578261333/activities
{
	"include_headers": "false",
	"advertiser_id_collection_enabled": "0",
	"event": "CUSTOM_APP_EVENTS",
	"application_tracking_enabled": "1",
	"ud": "{}",
	"sdk": "ios",
	"custom_events": "[{\"fb_transaction_id\":\"2000000315036248\",\"fb_content_title\":\"Dreamer Premium Annually\",\"fb_currency\":\"USD\",\"fb_content_id\":\"1489645075\",\"_ui\":\"off_thread\",\"_logTime\":1681806264,\"fb_transaction_date\":\"2023-04-18 11:24:09+0300\",\"fb_num_items\":1,\"_valueToSum\":14.99,\"_implicitlyLogged\":\"1\",\"fb_iap_is_start_trial\":\"0\",\"fb_iap_trial_period\":\"P3D\",\"fb_iap_trial_price\":0,\"_eventName\":\"fb_mobile_purchase\",\"fb_iap_product_type\":\"subs\",\"fb_iap_has_free_trial\":\"1\",\"fb_description\":\"Unlimited Vision Boards, Custom Affirmations\",\"fb_iap_subs_period\":\"P1Y\"}]",
	"format": "json",
	"extinfo": "[\"i2\",\"com.denimarina.dreamer\",\"158\",\"3.8.1\",\"15.7.4\",\"iPhone8,1\",\"en_US\",\"GMT+3\",\"NoCarrier\",375,667,\"2.00\",2,60,48,\"Europe\\\/Vilnius\"]",
	"url_schemes": "[\"drbrd\",\"fb395012578261333\"]",
	"advertiser_tracking_enabled": "1",
	"access_token": "395012578261333|3c79dc5664c1e9acb405e423b17bfc82",
	"anon_id": "XZ42AD95B7-4C1C-4371-9633-62E28FB49670"
}


{
	"success": true
}

maximaleks avatar Apr 18 '23 08:04 maximaleks

Previously in FB iOS SDK 15 StartTrial was sent after trial was activated:

{
	"include_headers": "false",
	"advertiser_id_collection_enabled": "0",
	"event": "CUSTOM_APP_EVENTS",
	"application_tracking_enabled": "1",
	"ud": "{}",
	"sdk": "ios",
	"custom_events": "[{\"fb_content_id\":\"1489645075\",\"fb_currency\":\"USD\",\"fb_iap_has_free_trial\":\"1\",\"fb_iap_subs_period\":\"P1Y\",\"_ui\":\"off_thread\",\"_logTime\":1668581773,\"fb_transaction_date\":\"2022-11-16 08:56:06+0200\",\"fb_num_items\":1,\"_valueToSum\":14.99,\"_implicitlyLogged\":\"1\",\"fb_iap_is_start_trial\":\"1\",\"fb_iap_trial_period\":\"P3D\",\"fb_iap_trial_price\":0,\"_eventName\":\"StartTrial\",\"fb_iap_product_type\":\"subs\",\"fb_description\":\"Unlimited Vision Boards, Custom Affirmations\",\"fb_content_title\":\"Dreamer Premium Annually\",\"fb_transaction_id\":\"2000000203830320\"}]",
	"format": "json",
	"extinfo": "[\"i2\",\"com.denimarina.dreamer\",\"156\",\"3.5\",\"15.7.1\",\"iPhone8,1\",\"en_US\",\"GMT+2\",\"NoCarrier\",375,667,\"2.00\",2,60,51,\"Europe\\\/Vilnius\"]",
	"url_schemes": "[\"drbrd\",\"fb395012578261333\"]",
	"advertiser_tracking_enabled": "1",
	"access_token": "395012578261333|3c79dc5664c1e9acb405e423b17bfc82",
	"anon_id": "XZ4BB2E781-8D6C-413C-81C3-0EB39E0B8DE2"
}

maximaleks avatar Apr 18 '23 08:04 maximaleks

When will this be fixed?

Karllas avatar Jun 18 '23 10:06 Karllas

+1

eddielement avatar Jul 18 '23 21:07 eddielement

Is this a bug or a feature?

Karllas avatar Sep 21 '23 03:09 Karllas

Hi! Any updates on this bug?

olisovenko avatar Oct 12 '23 17:10 olisovenko

Anyone knows when this will be solved or if there is a workaround ?

lucasiturbide avatar Nov 21 '23 18:11 lucasiturbide

Hello, has this been fixed? We face the same issue - Facebook iOS SDK version: 17.0.0 We upgraded from v15.2.0 (we used this version for over half a year) and released live but then realised the StartTrial and Subscribe were not logging, only the Purchase. We cannot revert to using older version because of other constraints.

YankoSoulisimo avatar Apr 22 '24 10:04 YankoSoulisimo

Hello, Same bug here, that I could reproduce with versions 16.3.1 and 17.0.0 of Facebook iOS SDK. I debugged the SDK to get more insight. I found an explanation as for why Free Trials are reported as "Purchase" events... but unfortunately it does not bring us any workaround.

Here is what happens:

  • App Events related to InApp purchases are logged by a class named FBSDKPaymentProductRequestor (last commit on this class occurred on Oct 18, 2022).
  • The method that logs purchases/subscribes/freeTrials is logTransactionEvent: https://github.com/facebook/facebook-ios-sdk/blob/v17.0.0/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/FBSDKPaymentProductRequestor.m#L127
  • The behavior of this function strongly depends on the value of a boolean setting named FBSDKGateKeeperAppEventsIfAutoLogSubs, provided by an object called gateKeeperManager:
    • if AutoLogSubs is true, then a new subscription will be reported as a StartTrial or a Subscribe event (method logImplicitSubscribeTransaction)
    • on the contrary, if the AutoLogSubs setting is false, then any new subscription will be reported by AppEvents as a FBSDKAppEventNamePurchased event, aka fb_mobile_purchase, aka "Purchase".

Putting a breakpoint in FBSDKGateKeeperManager, it appears that the GateKeeper settings are a bunch of approx. 50 boolean flags that are fetched from Facebook servers at app start :

(lldb) po gateKeeper
{
    FBSDKFeatureAAM = 1;
    FBSDKFeatureAAMR1 = 0;
    FBSDKFeatureAAMR2 = 0;
    FBSDKFeatureAEM = 1;
    FBSDKFeatureAEMAdvertiserRuleMatchInServer = 1;
    ...
    FBSDKFeatureUshbaLogin = 1;
    FBSDKFeatureWebViewSchemeFiltering = 1;
    "app_events_if_auto_log_subs" = 0;
    "app_events_killswitch" = 0;
}

It was no surprise to discover that, in my case, app_events_if_auto_log_subs is 0, which explains why free trial events are logged as raw Purchase instead of StartTrial.

Now, this explains why the SDK interprets new free trials as "Purchase" events... but it does not explains why for this app project the "Gate Keeper" parameter app_events_if_auto_log_subs is false. I found no setting in the Event Manager web interface that could be related to the value of this flag. Is there anything that should be done on project configuration side to enable the correct logging of StartTrial events ?

Also, while inspecting the body of a fb_mobile_purchase event sent when purchasing a subscription with free trial, I noticed that its payload contains:

  1. A flag custom_events.fb_iap_is_start_trial whose value is 1,
  2. The full Apple In-App purchase receipt of the user.

So I guess it could still be possible, given either 1. or 2. above, to translate automatically Purchase events into StartTrial on back-side, in case the Apple receipt and/or the custom_events.fb_iap_is_start_trial field say they are triggered by a Free Trial activation.

Either way, just as the other developers who commented this issue, I think it would be welcome from Facebook to indicate what has to be done so that Free Trials are correctly reported as Start Trial instead of Purchase events, since this analysis tends to show that the problem has (at least in part) some roots on Facebook side.

Thank you!

hberenger avatar Apr 29 '24 17:04 hberenger

Same issue. Some guidance from FB would be great.

almahdc avatar May 07 '24 16:05 almahdc

+1

MateoParodi avatar May 13 '24 14:05 MateoParodi

+1

SnowStorms avatar May 15 '24 08:05 SnowStorms

+1 too

HugoLec avatar May 23 '24 16:05 HugoLec

+1

Artfire avatar Jun 04 '24 16:06 Artfire

Will be fixed this problem? Or it's a feature?

xdstack avatar Jul 30 '24 06:07 xdstack

+1

denirorobert avatar Aug 05 '24 15:08 denirorobert