Lifecycle metrics are valuable, out-of-the-box information about your app user. These metrics contain information on the app user’s lifecycle such as device information, install or upgrade information, session start and pause times, etc. In this video, see how to set up lifecycle metrics in your app, and how to see the results in a debugger.
In this video, I wanna talk to you about lifecycle metrics, which are part of the Adobe Experience Platform SDK that you’ll use for your mobile app tracking for analytics and other solutions in the Experience Platform. Now, you can see here in this documentation, the lifecycle metrics are valuable, out-of-the-box information about your app user. They’re about the lifecycle of your user like device information, install, upgrade information, session start, pause times, et cetera. So, that’s the stuff about the device and the environment. Now, here in the documentation, it will walk you through how to install this and everything, but I just wanted to kinda show you in a quick video how easy it is and how you can use it, how you can set it up, and then what you’ll also see when you apply it in your app. So, as you can see here, we’re going to import some core libraries, et cetera. Well, this all starts with Launch because this is where you’re actually going to implement the SDK. So, I’m in Launch here, and there’s other videos that will walk you through this, so I’m just going to point out the parts that really are applicable to lifecycle metrics. So, here I am in the iOS section, and so you’re going to use CocoaPods and you’ll see here that there is a pod for the ACPCore, and lifecycle metrics are part of the core library. I’m going to select Swift instead of Objective C, you can use either one for iOS here, but I just wanna show you that based on the different extensions that I’ve selected here, it will have an import statement, but the one I’m most interested here is import ACPCore. So, now the library has been imported and then there is some additional stuff here that you’ll use to register. You’ll register the lifecycle right here and you will then start it, and you’ll see this data right here. So, I’m going to show you this in Xcode, I just wanted to show you where you’re gonna get it. You’ll get it here from Launch and then you’ll apply it in your app. So, if I jump over to my app here, and I’m in my AppDelegate.swift file, I can see that I have added those things I have imported, the ACPCore library, and then in my didFinishLaunchingWithOptions function here, then I do have the lifecycle registration here of the extension, and then the start of it right here. So, putting those in here is all you really need to do in order to get lifecycle up and running. And so, if you really just follow the instructions that are provided to you in the documentation and then here in Launch, you can see in the background there, then you will be able to have the lifecycle metrics and you’ll be able to see all those data points, and those are also here in the documentation. If I just click on Lifecycle, right above that piece, then you’ll see that in the documentation, there’s a list of all the different metrics and dimensions that you’ll get just simply by putting in this, you know, one line of code or at least a couple lines of code. So, pretty easy. So, if I do have that there, then when I run my app, and I’m just gonna run and let me show you here I have my simulator there, and if I just run this code.
And when it comes up, one of the hits I’m going to get here is, in fact, my lifecycle hit. So, you’ll see all this different information that comes in here based on just really having that line of code there that says “start lifecycle tracking”. And so, that’s pretty much it. Now, you’ll see there are couple other hits here. One is that it is registering a CrashEvent and that’s just because I stopped my simulator and it looked like a crash. And so, this is good anyway to show you that if you do have a crash, then when you restart that app the next time or when your user restarts their app, it will send a crash event so that you know how many times your app is actually crashing, so you can take a look at that and fix that better for your users. And so, that’s pretty much it as far as getting it up and running. If for some reason, you didn’t want lifecycle, then you can just get rid of this line to start it and then those would not appear there at all. You would not have your lifecycle metrics. Not sure why you’d wanna do that because it’s great information, but in any case, you do have control over that. Now, one more thing to show you before I let you go here and that is a best practice with lifecycle. And we’ll go here, maybe I’ll make this a little bit bigger so we can see a little easier. But you will have in your app a DidEnterBackground and then WillEnterForeground function here for each of those. Now, it’s not required, but it is a best practice to actually put in an ACPCore.lifecyclePause event when it goes into the background, and then, again, a lifecycleStart, which is basically a Resume, when it comes back into the foreground. Okay? So, pause it when it goes into the background and start it again when it comes into the foreground. Now, it’s not gonna actually give you a hit from those, but it will simply affect the time-based lifecycle metrics, so it’s not counting the time when it’s in the background for some of the lifecycle metrics, et cetera. And I had put here just for fun a trackAction just to push and hit to say, hey, I’m back, but that is just me goofing around here, and you don’t have to put that one in. But your best practice here is to get it to do a pause when it goes in the background and then to do a resume or this lifecycle.Start as it comes into the foreground again. And that’s pretty much it. Good luck with these great lifecycle metrics.
For more information about Lifecycle metrics, please see the documentation.