=== Aggregation === All event data is stored in the same data structure in order to simplify the aggregation process. Traditionally, offline batch jobs must be used in order to execute complex aggregations in a Business Intelligence and Analytics platform. We use a simple data structure to store everything, and use the same fields for similar data. Using this model most aggregations can be executed directly in the dashboard without requiring the creation of complex jobs. For example, suppose we want to see the Heat Map showing the regions where my latest Scratchcard campaign was more engaging. We are going to measure this by filtering the dashboard to show the location of the SCRATCHED event that is triggered when an user scratches a Scratchcard. We can start with the **Main Events Dashboard** which contains all the elements needed for most Analytics tasks. The base dashboard shows all the events for all the applications, locations and types. If you scroll down to the **New Events - Heat Map** panel you will see all event types for all applications distributed in the map: \\ \\ {{ :agg1.jpg?1000 }} \\ \\ But we want to only see data for Scratchcards, so we scroll the dashboard and look for the **New Events - Applications** panel. You will see all the applications that report events to the platform (and all the event types mixed altogether): \\ \\ {{ :agg2.jpg?1000 }} \\ \\ Now, click on the **Scratchcard** bar to add a filter that will only show events for that application. As you can see, now only events for the Scratchcard application are being shown: \\ \\ {{ :agg3.jpg?1000 }} \\ \\ Note that now the **New Events - Event Types** panel only shows events relevant to the Application we selected: OPEN, TIMEOUT, SCRATCHED, PLAYED and CLICKED. We want to see the data for the SCRATCHED event, so we click that bar: \\ \\ {{ :agg4.jpg?1000 }} \\ \\ We now are down to 36 events, and the **New Events - Time Distribution** chart shows that December 4 at 9am was the moment that most customers scratched the Scratchcard. But we are still seeing the data for all Scratchcard campaigns, as we have not added a filter that restricts the data to the campaign i'm analyzing. If we scroll down we'll see the **New Events - Campaign Names** panel which shows all the Scratchcard campaigns that have generated SCRATCHED events. We can now click on the campaign we are analyzing: \\ \\ {{ :agg5.jpg?1000 }} \\ \\ If we scroll back up to the top of the page we ca see that three filters have been added to the dashboard: \\ \\ {{ :agg6.jpg?600 }} \\ \\ We have now added all the filters and aggregations that we need, and can now see the map we wanted from the beginning: In which regions was my Scratchcard campaign more engaging?: \\ \\ {{ :agg7.jpg?1000 }} \\ \\ Now we can see that there are two main areas for this campaign: The Caribbean and Europe. But we may ask ourselves, what types of interactions have my users had on each of those regions? Was my campaign more engaging in one region than the other? Maybe I need to use different Scratchcard graphics in certain regions? We can keep digging, adding filters and aggregations to see the data from all possible angles. Let's remove the filter that only shows events of type SCRATCHED. For this we scroll back up, look for the **event_type: SCRATCHED** filter and click the remove button: \\ \\ {{ ::agg8.jpg?600 }} \\ \\ Now that the filter has been removed we can see all the event types for the selected campaign (since we left the other two filters intact): \\ \\ {{ ::agg9.jpg?1000 }} \\ \\ We can now scroll down to the **New Events - Heat Map** panel and draw a rectangle in The Caribbean (refer to [[Location]] if you need more info on how to filter maps). Now our dashboard only displays events in that area: \\ \\ {{ ::agg10.jpg?1000 }} \\ \\ You can scroll back up and see what kind of filter was added to the dashboard. In this case it's a lat/long filter: \\ \\ {{ ::agg11.jpg?700 }} \\ \\ Now, if we look at the **New Events - Event Types** panel we can see what types of events were registered for this campaign in The Caribbean: \\ \\ {{ ::agg15.jpg?700 }} \\ \\ It seems like engagement was high: only one user that clicked the link did nos scratch the Scratchcard. Now, Let's modify the filter and see how we did in Europe. First we remove the location filter for The Caribbean: \\ \\ {{ ::agg13.jpg?1000 }} \\ \\ And we add a new Location filter, now selecting only events in Europe: \\ \\ {{ ::agg14.jpg?1000 }} \\ \\ Now we can check the **New Events - Event Types** panel: \\ \\ {{ ::agg12.jpg?700 }} \\ \\ Now look at that, we did not do very well in Europe: more than half the users that clicked the Scratchcard link did not scratch the image. We may decide now to send a different Scratchcard to users in europe, with maybe a different wording in the initial image to increase participation rates. \\ \\ === Queries and Advanced Filtering === Tradditional filters can be used to cover most use cases when we want to analyze data for a single campaign, or a single application, or a single event type. But what about analytics across multiple channels, campaigns or applications? In those cases we can use Queries and Advanced Filters. Here's a sample use case: My Store is a retail store that wants to use Scratchcards to send coupons to users that have visited their store. [[Scratchcard|Scratchcards]] are a great way to deliver codes, coupons or offers to users through gamification. Now, not all users will receive a coupon: My Store has decided that 50% of their visitors will get a coupon and the rest will receive a message thanking them for being a customer, so they will use a [[Raffle]]. They also want to use an EXIT [[iBeacon]] to trigger the campaign, that way only users leaving the store will be engaged and precision will be higher than [[GeoFence|GeoFences]] since it's an indoor campaign. We will need 4 elements in the Campaign Manager: * 2 Scratchcards * One Raffle * One iBeacon These elements can be configured using the Campaign Manager web interface. For this example we created these two Scratchcards: \\ \\ {{ ::filter1.jpg?1000 }} \\ \\ MY_STORE_LOSE (the one that will receive users not selected for the coupon) looks like this: \\ \\ {{::filter2.jpg?400}}{{::filter3.jpg?400}} \\ \\ MY_STORE_WIN (the Scratchcard with the coupon) looks like this: \\ \\ {{::filter4.jpg?400}}{{::filter5.jpg?400}} \\ \\ The Raffle was configured as follows (please refer to the [[Raffle]] documentation for more info): \\ \\ {{ ::filter6.jpg?1000 }} \\ \\ And finally the iBeacon was created and the Raffle campaign was associated with the EXIT event (please refer to the [[iBeacon]] documentation for more info): \\ \\ {{ ::filter7.jpg?1000 }} \\ \\ Now, several customers entered the store, then exited, received the Scratchcard and participated in the campaign. We want to look at the aggregated data for all the elements in the campaign. We can now head to the **Main Events Dashboard** and add the following query: ''campaign_name.raw: "My Store Exit Raffle" OR campaign_name.raw: "My Store Exit Beacon"'' \\ \\ {{ ::filter8.jpg?1000 }} \\ \\ We are now seeing only events for those two campaigns: \\ \\ {{ ::filter9.jpg?1000 }} \\ \\ But wait, what is this CRT_BEACON event displayed in the **New Events - Event Types** panel? \\ \\ {{ ::filter10.jpg?1000 }} \\ \\ As noted before, all events generated within the Campaign Manager are registered, even internal events between the Campaign Manager and the SDK. The CRT_REGION is the event generated when an iBeacon is created in the platform (specifically, these events we are seeing where generated when the users of our app received the new iBeacon we created in the previous step). Pease refer to [[Events]] for more information on the types of events. In this case we don't care about this event, so we can filter it out. We need to click on the bar in the chart, then scroll up and click on the invert icon for this filter (magnifying glass with a minus sign inside): \\ \\ {{ ::filter11.jpg?400 }} \\ \\ If we now scroll back down we ca see the events we are interested in: {{ ::filter12.jpg?1000 }} \\ \\ BEACON_EXIT events are generated when the user exits the iBeacon region, and the OPEN and SCRATCHED events are generated when users click on the Scratchcard link and scratch the cover image respectively. If we had several locations we could use different names for the iBeacons, add them to the query and then get an overview in the **New Events - Campaign Names** panel: \\ \\ {{ ::filter14.jpg?700 }} \\ \\ If we need to analyze the location data for the events, all events with a location element for any of the campaigns will be displayed in the maps: \\ \\ {{ ::filter13.jpg?1000 }}