Spy on Your Users with App Center Analytics!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] you want to know how to spy on your users and get some analytics out of your xamarin forms application come check out this video now for this one we need to start with a little bit of initial setup um we need to do that in the app center portal so go over to appcenter.ms i'm sure you can figure out how to set up your account um so when we do then you will get here on this landing page where we need to add our new app so let's do that straight away add new app and here is a couple of things that we need to fill out i will tell you a little bit about that let's just start with the name and we'll go to analytics sample there we go and here underneath you have i'm gonna skip over the release type it's optional you can kind of say like hey alpha beta enterprise whatever it's just kind of a label that you can know this app by um and and here we have the os right so you can specify ios android windows mac os tv os or even something custom because you know you can interact with this this is just a bunch of rest apis basically so if you have another platform that you want to support just figure out the rest api endpoints that are there and you can interact with that as long as you have the kind of the 8 app id that we are going to see in a little bit i'm just going to stick with ios and then also you can specify the platform down here so you can have also native objective c react native cordova and of course xamarin that's what we're going to see today so also the platform doesn't really matter so let's click examine um what you might see in this if you're going to work with this which is kind of funny if you're looking at it from a examined forms perspective is that you will have to create separate apps for ios and android or maybe windows because you have to specify the os here right i mean technically you could get all the data inside of one app if you if that's what you want here by just specifying one os and use that key for all the platforms um but you know it could be nice also for the reporting purposes to have all the data in separate kind of apps that's totally up to you so let's add a new app right here and then you can see you will get automatically this overview on how to get started for both examine and xamarin forms so you can do it for all the things i can't emphasize this enough so if we look at the kind of the instructions for examine forms it's slightly different than for examine and what you want to do is basically install the nuget package add the right usings add the right app id right here and you're ready to go basically now app center is more than just the analytics that i'm going to show you today you can see here on the left build test distribute diagnostics analytics please let me know in the comments down below if you want to see anything more about amp center for instance the crash management which is really cool as well but i'm going to stick for with the analytics right now so i'm just going to skip over these instructions right here the main thing to remember here is to that you need to get this little piece of initialization code or at least the app id from right here and also if you're going to do this for uwp and android create those uwp and android apps and just swap out the uwp and the android keys right here with the keys that you get from those pages now with that in mind let's skip over to visual studio and see how to actually implement this okay here we are in visual studio for mac 2019 on the left you can see it a file new examine forms application out of the box freshly opened here it is a bunch of example you can see it on the right running on the ios simulator and i didn't do anything here yet so let's just start up this app center goodness the first thing of course we need to do is update the title right here so let's make this analytics sample but then kind of spell to the right way right and i'll there we go another sample boom whenever we save that it updates the title automatically um on our running application by hot reload works on simulator android emulator and on physical devices which is really cool now i've copied that little piece of code that we just had to remember from the app center portal so let's go over to our solution actually we need to start with installing the nugets first so let's right click on our solution and say manage nuget packages and then whenever you search for app center a bunch of packages will actually come up so here we have kind of like the base app center package which has some common code here we have it specific for crashes analytics distribute and some other things as well we're gonna stick with the analytics and that will automatically bring in the app center common package as well so let's just do add package we are going to have to select all three platforms or more if you have even more because it also has some specific code to those platforms so you really want to add it to all of the platforms right here click ok we're going to have to agree to the license right here so make sure you read it and then accept it and then we wait for the packages to be added and then from there i copy the code from that app center portal to actually do the initialization code so let's just go over to that again i'm going to go to the solution and this for example informs you have to do it in your shared code so in the shared library if you're doing this for example regular traditional examiner then you might have to do it in like the platform specific projects but for examine forms we can do it in the shared layer so let's go over to our app example.cs and here in our onstart we are going to initialize these analytics right here so this is literally the pasted code from the portal and there is something weird in here well actually not something weird but something that we don't need because this also initializes the crashes which we are not going to show in this video so let's just remove that and then you can still see a couple of reds quickly so to solve those let's just let intelli cells help us click on the little light bulb and then say using microsoft.app center and for the analytics one we also need to do that so using microsoft app center analytics it will add the usings here right here at the top and now everything looks okay so what you do with this is you're gonna say hey this app center service is going to start on my device on my app you'll have to use this app id so that it knows where to send the data to on the app center services and here you're going to say hey i want to initialize the analytics service and if you want to add more like i said you can just do type of and then you want to have the crashes in here for example if you want to add the crashes as well but you have to add the crash's nougat package for that so that's something for another video let me know down in the comments below if that is something that you want to see now this is all we need to do to set things up and make it work actually now that we have this in place we can identify analytics events that you want to track so let's go back to our main page.example and what i'm going to do is remove all the labels right here and i'm going to add one button there we go with the text click me yes and a clicked handler let's just generate that for us closing tag and now we have this button you can see with hot reload it's already showing up it doesn't do anything yet so let's implement this button and let's get some other tracking events in here so we go to our solution the main page example main page example dot cs and now we see our button clicked and again we also need to add here the using microsoft.appcenter.analytics and now we can start tracking events so if we do analytics dot you you have a couple of things here you so you can also see if it's is enabled yes or no or you can set is enabled yes or no which is kind of important because you know local laws all those kinds of privacy things these days you probably want to have some kind of method to turn this tracking off or on so that's also an important thing right please let your users know that you're doing this be transparent about what data you're tracking so that you're not you know sending all kinds of weird data because if the users lose trust in your application they're going to uninstall it never use it again and that's in the best case scenario maybe they're going to put it on twitter being retweeted by thousands of people and suddenly you will have all kinds of lawsuits and whatnot so be very transparent about what you're doing here and careful about the data that you're actually sending back to your servers okay so having that said a little warning here be sure to do the is enabled make sure there's an option for the user to actually opt out or maybe better opt into the analytics but when you do you can just do the track event and with the track event at the very simplest form you can track an event by just specifying a name so button clicked there we go and whenever we do that it will just say hey this event happened basically and you will get some extra data we'll see that in the app center portal in a little bit but what you can also do is specify extra properties so if we do comma we see that we can also do a dictionary of string string with all kinds of properties which is basically a key value string thing right here so we can also say new dictionary string string and let's put something in here so this is kind of like the short format to create a new dictionary i'm forgetting one right here a little angle bracket there we go and um so let's just put in here how many times the user clicked on the button which is you know something that you could track so let's create a int i is zero and here we're going to say times clicked which is going to be our key and then here we can say i plus plus dot to string so it has to be all string values right so now each time we click we will get an event button clicked and we will get a property that will tell us how many times the button has clicked also let's see if our user even opened this page well they're going to open it because it's the main page but maybe if you're in some kind of navigation scenario where you want to track like hey how many times is this user going to land on a specific page you can just here do this track event and we can say page opened and we can say page and we can say name of main page so that we know that this is the page that we open maybe you want to wrap this in some kind of service of your own that makes it a little bit easier to use and then you can just see like hey or maybe you you're using this in a base page right so that maybe makes more sense a base page where you inherit from and this way you just have to write this line of code once and you can automatically track where the user is going through the pages in your application i mean how you implement the actual events that is totally up to you depending on what you want to track and how you want to track it but this is basically how to do it so let me save this and i need to stop and restart the application real quick because you know i changed some code so we need to redeploy the application for that to be picked up and then nothing really is going to be visible here in our application because it's all happening in the background but then we're going to hop over back to app center and see how the data kind of comes in so we're waiting here for the application to come back up and then the track event should already see like hey the page open so that happened and now let's click this button a couple of times so let's just click click click click click click click click click click click click um we clicked it a couple of times let me actually stop and and restart it again just so you can see some kind of different data coming in here as well and kind of like this is also important right that the user is not going to know this um and that's also the code for the app center has been designed to not crash your application so whenever something comes up whenever you don't have an internet connection it will actually cache the logs for up to 10 megabytes and then whenever the internet connection is back it will send that over to app center for you automatically in the background you don't need to worry about that so that is pretty amazing if you ask me but this code has been designed to never crash your application um so it all runs in the background and um yeah it should work automatically without you having to do anything besides tracking these events so let me click this button a couple of more times here we go and let's just hop over back now to the app center portal and see what this actually did okay back in app center this is exactly where we left off i even selected the text here that i actually copied so let's go over here on the left to analytics and here you can see that we have kind of a couple of more categories overview events and log flow i'll go over these very briefly and here at the top you can see a very important note as well learn more with application insights so what is really cool that you can also set up a sync to application insights to azure application insights where you have more query capabilities and more data visualization options but even more so the data retention on app center is i think at most like 30 days or 90 days but if you stream it into azure then not only will you have the extra query capabilities but you can also keep the data there for a longer period of time so but let me dismiss this for right now that's something for another day here you can automatically see in the overview like how many active users you had that's something that you didn't need to do it will automatically see like how many times a unique user has started your application and here you can see kind of like the trends daily weekly monthly and you can see how many users actually did that now this is of course you know very short-lived i'm only putting the data in there now but if you get more data then you can also see daily sessions per user so how many times did a user actually start your application you can see how long those sessions were so the session duration and you can see which devices your application is used on so now right now you can see the simulator on os ios 14.5 but especially if you add android here in the mix then you will see a variety of android devices in here with a big number of different os versions probably but you can see like hey if i want to make this update for a very specific android version is that worth it is that um for only one user or is that for 10 000 users that you know based on that information you can see how high priority a bug should be for instance also you can see from which countries your application is used which languages are set on the user's device and how many active users there are per version so if you're releasing multiple versions of your app you can see how the adoption rate is for new versions maybe people are hesitant to update to a new version and then you have to figure out why and make that better so this is already a lot of data that you can use and she didn't even have to implement anything for this besides just initializing the app center apis that is pretty cool now for the events that's maybe even more interesting than all of this so here you can see the events you can see right now the data hasn't come in yet so let me refresh that in a little bit but if you go in here you can get some instructions on how to actually you know track that event but i've already just shown you so let me go over to the log flow first and then come back and see if there's actually already some data in here that we can actually show you so the log flow is actually even cooler here you can see if we go over there it will say away data from your app and you can connect to this and really get near real-time data from any application so this is basically the log the events coming in and this can be really useful in kind of the scenario where you might have a bug that is hard to reproduce or you know i don't know something else that you want to real life track some maybe you're doing some user study and a user is going through the app and you want to follow along what they're doing then whenever the application is being run and they're going through the application your events are coming in here in real time and you can see what is going on now let's quickly go back to the events and we can now see that our button clicked actually came in so that is pretty cool and whenever we drill down in this button clicks you can see it already happened 29 times by one user and here's also you can see trends so the user change where you can see like how many users actually click this button maybe you can do some a b testing with this and whenever we click this you can even get more data and then here you can see it's just one user and you can see the the 100 of all users so if we would have more users you can see what percentage of your users is actually doing the button clicked you can see the count that the count that is um total for this event so for the button clicked that name is kind of like you need the unique identifier for um discount right here then you can get the the counter user the account per session and also really much down here you can see kind of like a list of the properties so in this case the properties is times clicked you can see that name coming back here and then the times clicked i did that little counter the i plus plus so in this case three one and five and and all the way down to two um you can see that this is like the most um click thing the most used property uh and down here there was this first time where i clicked really multiple times up to 12 times and that only happened once so you know the the data here is not really that great but if you define the right data that you want to track this is a really valuable tool to track your users and see how they are using your app and that is how super easy it is to use app center and add that to your application now this is not even specific to xamarin forms or examine you can also do it for cordova react native objective c all the native platforms so that is super duper cool if you ask me so you can still use this tool even if you're not doing xamarin or xamarin forms now i already mentioned this during the video but please be very transparent and careful with the data that you gather from your users because you can put everything in here right everything that the user is entering here you can put that in here and send it over back to app center um please be very transparent and careful with the data that you actually do use it to make your app better but not to actually spy on your users although that is something that i might like to make this pun on of course with this video but please don't actually do that for the rest please like this video if you've actually liked it subscribe to my channel if you haven't done so let me know down in the comments if you have any questions about what happened here or if you want to see anything more from app center other than that i'll be seeing you for my next video keep coding [Music]
Info
Channel: Gerald Versluis
Views: 1,624
Rating: undefined out of 5
Keywords: app center, app development, app center ios, app center android, app center analytics, app center xamarin forms, Xamarin.Forms, xamarin forms tutorial, xamarin forms 5, xamarin forms app, Xamarin.Forms 101, xamarin forms app center, event tracking, App Event tracking, Xamarin event tracking, xamarin tutorial, xamarin tutorial for beginners, xamarin 101, xamarin app, microsoft app center, microsoft app center ios, visual studio app center tutorial
Id: LnXf-ij1eUU
Channel Id: undefined
Length: 19min 9sec (1149 seconds)
Published: Mon Sep 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.