FIRST APP GUIDE
Analytics Integration
Time to see how your users interact with your app! Let's add Mixpanel analytics to track key events like page views, button clicks, and feature usage.
Adding the Mixpanel Block
Just like we did with the FAQ block, let's add analytics support:
codika add-block -b mixpanel
What Changed?
Let's examine what this command added to your project.
Notice something interesting? This new class implements IAnalyticsRepository
- an interface that was already in your project!
Setting Up Your API Key
Before analytics will work, you'll need to add your Mixpanel API key:
- Get your API key from Mixpanel
- Add it securely to your project:
codika secrets set MIXPANEL_TOKEN your_token_here
This command:
- Securely stores your key
- Updates your Codemagic configuration
- Adds the key to your local development environment
Pre-Built Analytics Events
Here's the cool part - all your existing blocks already track useful events! Open up your Mixpanel dashboard and you'll see events like:
- Page views for FAQ, Settings, and other screens
- Button clicks and user interactions
- Feature usage statistics
This works because every Codika block is built to use the IAnalyticsRepository
interface, regardless of which analytics provider you choose.
Why This Architecture Rocks
This design gives you incredible flexibility:
- Want to use Firebase Analytics instead? Just create a new implementation!
- Need to send analytics to multiple services? Create a composite repository!
- Testing your app? The fake implementation works without any setup!
What's Next?
You've successfully:
- Added professional analytics
- Secured your API keys
- Unlocked pre-built event tracking
Next, let's explore how to customize your app's look and feel to match your brand!