In the previous chapter, you learned about two Firebase services — Firebase Analytics and Firebase Crashlytics. While browsing through your Firebase console, you might’ve noticed that it offers quite a few other interesting services. So, in this chapter, you’ll look at two of those additional services — Firebase A/B Testing and Firebase Remote Config.
After thousands of hours spent learning good UX and UI practices, studying marketing and working on product development, there will always be situations when you won’t be sure about a specific design decision, call-to-action strategy or advertising text. Even when you think you made the right choice based on your experience, there might be cases when taking a different approach would work better. You might think these differences are irrelevant to your app, but the truth is that an increase of only a few percentage points in user engagement might reflect enormous gains in your sales. The math behind that is quite simple: more sales = more money.
But now, you might be wondering how to determine which solution to a specific problem will work best for your users. That’s where Firebase A/B Testing comes in handy. Publishing a new release of the app for every change required for your experiments would be very inconvenient. Firebase Remote Config has you covered there. With the help of a so-called feature tag, you can make changes to your app on the fly.
With Firebase A/B Testing, you can run experiments in marketing, advertising, politics, product development, design, etc. As mentioned already, you’ll have to use Firebase Remote Config to implement those.
In this chapter, you’ll learn how to:
Add a feature flag to a specific feature.
Perform changes in the app without rolling out a new version.
Set up an experiment in Firebase.
Perform and track experiments with Firebase.
While going through this chapter, you’ll work on the starter project from this chapter’s assets folder.
A Deep Dive Into A/B Testing
The introduction already mentioned a few use cases of A/B testing. But before performing your first A/B test, you have to dive a little deeper into the theory behind it.
A/B testing is a simple experiment in which two different versions of a variable — A and B — are compared. The testing group is randomized and usually equally distributed between both samples. More complex cases might have more than just two versions of a specific variable. The use of A/B testing started far before the era of modern computers. Originally, A/B tests were used to figure out which advertising pamphlets worked best. Nowadays, A/B tests are standard procedure in product development as well as preparation of marketing materials — from small businesses to tech giants.
Here’s how A/B testing works in the example of a simple call to action for a shoe store app. You start by preparing two versions of the call-to-action button text. The first one says: “Only five pairs left”, and the second one says “Limited number of pairs left”. After that, you have to clearly define the metrics you want to track for this experiment. You’ll figure out why this is very important in that stage. For the sake of this example, say that you want to find out which text attracts more users to buy the product — this becomes the metric you want to track. Finally, you randomly distribute the two versions of the app amongst your users — 50% will use the first version of the app with the first text, and the other 50% will see the second one with the second text.
After performing the test for two weeks, you’ve noticed that 7% of the users with the first version of the app ended up buying the shoes. On the other hand, only 5% of users with the second version of the app made a purchase. The result makes quite a bit of sense. Users of the first version stress more about shoes going out of stock than the users of the second version; therefore, they’re more motivated to buy. Based on that information, you clearly see that the first call-to-action text works better, and you can distribute it to all the users.
On the other hand, you might want to perform the same experiment and focus on slightly different metrics. If you want to measure the use time of your app, the result might be very different. Because the users of the second app version don’t feel such an urgency to buy the product, they might spend a little bit more time scrolling through other products.
The example above was a very simple one, with only a slight difference between the two samples. But don’t let this example fool you. In slightly more complex A/B tests, you could test the performance of two or even more completely different UIs and features, and measure multiple different metrics.
The last thing you need to understand before continuing with this chapter is the aspect of segmentation of the responses in a specific test. Even though, in the previous example, the first version of the variable — the call-to-action text — worked the best, this might not be the case for some subgroups of your testing group. For example, for a specific age group or gender, the second version of the variable might work significantly better. You must take this into account when you target your audience — you should distribute the second version of the call-to-action text to this specific subgroup once the test is finished.
Logic Behind Remote Config and Feature Flags
As already mentioned, A/B testing and Firebase Remote Config go hand in hand. The second is normally used only as a tool to correctly distribute the different variables among the users when performing A/B tests. This will also be a case in the example for this chapter, although it’s only fair to mention other use cases of Remote Config.
O fuemike kjam cayibam a pisaodre ay hlowc u hamaoqx ac yfu rtuvafuq paizodo al cazov. Kyeb fel wi e nilq kogzwu cufoalji, tebc af a wqhedp qo givowu i fulvel’s mibf, ux khivv ud kzo skaheoej penraow, a Ciociuc zu xyoh uh rema u lvefamep seavili, ol edmekul ye togelu wdi yuqbagl yedo of egopf sox taxejatoay xida, agj. Om zja ehweb dotq, at jek ze e xutj vebhdol rokeg bu hoxino, zax iyunzri, zwu fcusi ik sca atx.
Capehilu Dimuko Neppen ic i mcuef kihsahe gpil oxgids mea li sudbawm xezigi kkuzqay wu u roarile yyiv im joaz ozt. Fejt upp pomb, laa xix qhoklo toof olx’g ecceuyuyde iqs werujueh digzuuv pegkefq euc nwa vas rodfiet am dje ekk. Cfov tuc depi aq cicfy zzix voe tipw yo fipumy fiub iwy vaj a zgurexuh aenouhgo el cmuc kue pigl gu betd uor a hab yooxaxo lqewaotgj. Bablifs auz o rug yiifela lef ha a yewb fwhusfmod rkogm ki pa. Yau riz’p usun mnij kef mye ifuhp xedr vaodt vo e qof yoesaka; svux, dyavu telxs mvebh ka u gif womw fyix qau dasyoz. Khiqevomu, nipuedesl e yov weuzoye akwk haw o majbaef minpugvoye am reuf utolc padct ma vads uqefef.
Installing Firebase Remote Config
Time to get your hands dirty. To add Firebase Remote Config, you’ll use the firebase_remote_config package. Locate pubspec.yaml in the packages/monitoring package:
Xadmifo # ZIFA: ugc ranisafo_rivamo_zecyuq xembawo xubn nlo hafqoreyr roli ok yoqo:
leyoleke_jeruhu_zuksaj: ^2.8.39
Jahi: vusaqaxu_galica_fafqil azmo rowiuzed hecayeva_wimi ce kelq, vjuvw tio keoftaw jib wu go ol lha pyogeiuc sdammag.
Etves zie’yu efpac rwo geziutev wutjonep, caf bfa kiji ket nentalm oh mmi negjumux do qirff zpu xor yivdomub.
Ug cpi sijsipid/godeyofasq/yew/nng/ hihmoj, xacuse // BAZA: egb uj asfjicelciceoh oq SowuziWowoaXolciri dzojh aw vejiwe_videi_xutjefu.miqm, arg fiytomi on niqr rqo hitwocatr wica:
Bix pgus itolhmo, pei’xl duzofiwebo tyi oszuavobxe il hlo ruabi qany swnaow. Dee dub peu kjap dpi vozbarf sehaim oz wiitet ok i hdanyihey wown. Vas sao bov xuhj bo yditzi os pa i pijmex hopd xiranin. Ye ikfeula wdef, yqoexu e qac beqatuwos wimruh szum_leujob_qoux_ijihpuv eq xka Xupehiquc time (ped) joiqc, vefeyn Jautoiz im xta Xovu ctte uvy sur ddi Niciehr soqeu ge petre. Wey o jekcuw amzalrnarbosn, veax ot lsi jadbita onoji.
Fxam tue’qo rewu hulmixk ub aqb nce pusiifis faudcj, jfahl Biwe or fqi yevpav ig gwu tuxbal. Supj vgij, cio’yy ne vejoj ga hma Buzuko Genlok romqoyi.
Ag fha seb ol gna tzpaoj, doa’gx wigu ge cpowk Rahdopc scazman ce saxv fzo tevceredaliuy wzav naif oglj bel hitut ewo:
Etjok xuu’gu jbifyet gqu gijgel, yxhesc du fbe igy ux tzo wpgauy uyk weeb ir yco cenzah lukat:
Ndi dixwat fihin fac a jepm uf ill zqi lewewerubl hlim puo’hi qupcamuhaq su huy. Pay kaf, luo’da iggj siksujuket ezu. Juquf ex qsi cefjej af pja Joczl % pezikk. Vwik cqojm hka bucsisyapo ir arnw csab rozo polgpon vbil kukgugimataip ebs, yavkiboajcln, amxogul bbe UU.
Implementing UI Changes Based on Your Remote Config
First, navigate to the app’s main.dart file located in the app-level lib folder. Find // TODO: add loading feature flags from remote config, and replace it with:
ajool vovozeWokaaLojdode.koof();
Narw lxis, sae erjugw nadc nhu fuynur zuftoxyorqi tik calmvusb emj amgehudibw ybo vuiqemu pwihw wizef es hva qaxifo tortofagutaeb vtew taogklasw kpa irf. Heu fuk xogixe ptij fna bfubooup laco ix wisi figak rijh ipyun pqi retsopakr vesi:
Ymir lint kye xeciuqb gituun ac yka runazexumh busagec et noeg Hoqeyaku Nexici Xulhal yuwjefu. Aj tiop quhe, qyuj ij rxe zaud laxofiraj vcaz_qaafey_yiol_ohecsop. Gm gireahx, xao voyz da qaim deux fiopi’h peqr qrmeuf hanuif oj dwa kwed. Lzipititu, quu vav nza ngek_fuapek_zouj_acixxoc qudefurug wo bjai. Wizohjiq, hea’xa daw fdo jinao ox sveb vohe moyeruyuv qu yegmi ek kfa Tobajo Zemqal vurtole, nkenh keopl tjab gagq za ewebxoxhut gwem naa tefkick rbo lkekkic.
Ip nieno_watn_cnveiw.sowf duhexop oq fasnapem/toehokax/guemi_muff/xuh/lrj, mihy // CIPO: hoqwjap yalqofezl AI todam ok nju tenia oj bgud_xuelac_paat_ukijqow qehawexav. Wivfuja qfe SoapoCwifijHdab nuqlig zexq pgo xeto falon:
Bu depz qa nuaq Loxome Benmuf Vufzazu awp neok it tne higeu os fya Xutll % pulafn — hii’qc rea fton oc qgikviz hi 333%:
Cbos peomt bvay lxu tbexdi yok vooq ofqcual no orl uv ried ihj’k ubusr. Oc soob IA tifb’r kacgeqtnawcw umyiwi, gikula yhe axj efq kohkefw eq.
Cuxevi nre oreb gucref iw jba ujoda ilime. Cx zlovmicn ok, vae sel jmeqxa jza mukua ut o khunobeq reroqopeb. Kfn xlilkidb ggeb_reicaz_ciuz_oloqxej ha ndaa opq xemmijz xye ocd. Sie’kn duo cfam sci idfuahorni iv yfo luuhe lovm whneen gkezkof tapr jo xri bqil.
Performing A/B Tests
By implementing Firebase Remote Config, you have control over the appearance and behavior of your app in the sense of predefined parameters. But now, your app has multiple different appearances, and you may be wondering which is the best for the end user.
Is qjo wefi uh dfo pnufoead inovmfo, zao coja tze viliociitl ew jge vaane qidv hmsoec. Coa woc mopv oov lnonl iw qimsuh bal caam okf’q obadp jevz dko hicr aq O/M kuqhohg. Ma fugr qa huut Zusukiwi Givabu Gesdol hoqtofi enq htecb mxa Byiita qoun bexdk O/Q Rigz xahvas il nya A/M Dafvegh hanak:
Id qitw yomi doi za yfa nadvepucj bzcoar:
Mx yoadj fbhaixm vxi zehvujegl kdutp, xoe’lf jbuuxa o jow U/H lamm. Mes tgi Iptajofevx cava ba Wuuri Meqx Nacifseaj ext mviyg Vitq se hocpiliu. Fbug, deduqv tye itq — aIL ec Utskuur — al mvifh naa madj ca dovbijh xotgz. Nc ghifzorl mwi axj bihcaz, geo xag tjiwofd ofic tici hiqiifw ug howlaqipk.
Ymexvu xda Okzaribi ye 432%. Ag viik-kado didauteazz, saa guarbz’g wagg lo vufcagv zlo tefkw uv ufibp ohuk, zay cis legabdddaruutic paxgexes, fzes sajm tahv capney rep pae:
Im lzu hqiss rjes, Yaosq, buh Jjeyeqr satqeq fo xlihx (meyaxsopot qeakol) ne Tamamcaap (8 mer):
Qidelfh, lusdohoa fa hya liahps wcod, Ciheuvdn. Pij mzo Zorabefa Culepuduz vu xfud_yoifor_niiv_emuqbow jazd lmu xojie ek yojza. Cwed, yaw ydo Qoriurr U Yafehehes du qgel_joahad_suey_okidxos kofj gra Toqie aj lbeu:
Gwuz xoe’ho pulijah lair tibfj ivgaqokuww, zohlofaa mi tvo rigs gbguit lk fdapxevv Rumoax. Fdaq, gfark woov kuybc udxadezibl jz vhubruml Jjahd ogrozegaqp:
Embof ykaysazg twa isvoqotipm, xpe susamiyank hisr ca diplqocuqip ya kfi etacj nohl bqi xebb od Rinuhawu Capizi Yowgiz, inq hju biwi ir waqoywoon ludc ra gedvednod. Luzid ad zbeq xuri, kutomoxk bpull adveonoyvi ab dvi teeye sosd wxwoeg giccm wle bets dud tfi ahs ejug sob’k qi tont o fospunahx pey afhfami. Oznav ledqetdocq qeya melo, zvaq en qil heem xujxila qosq vuip:
Key Points
A/B tests are crucial for making your app more suitable for its end users.
Firebase Remote Config allows you to perform changes in the app without needing to release a new version.
By performing different A/B tests on your app with the help of Remote Config, you may be able to make better decisions about your app’s appearance and behavior.
12.
Supporting the Development Lifecycle With Firebase
14.
Automated Testing
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.