Cordova Example App
A comprehensive Cordova/Ionic application demonstrating all Trackier SDK features with complete implementation examples.
Overview
The Cordova SDK Simulator is a fully functional example app that showcases:
- Complete SDK Integration - All Trackier SDK features implemented
- Real-world Examples - Production-ready code patterns
- Cross-platform Support - Android and iOS compatibility
- Modern UI - User-friendly interfaces for testing features
- Comprehensive Logging - Detailed debugging information
Key Features Demonstrated
SDK Initialization
Complete setup with environment variables, platform-specific configurations, and Firebase integration.
Event Tracking
- Built-in Events - 15+ predefined events with revenue tracking
- Custom Events - Flexible custom event implementation
- Revenue Tracking - Multi-currency support
- Parameter System - Dynamic parameters (up to 10)
Deep Linking
- Immediate Deep Links - Direct app navigation
- Deferred Deep Links - Post-install attribution
- URL Resolution - Advanced link parsing
- Navigation Handling - Seamless user experience
Dynamic Links
- Link Creation - Template-based generation
- Multi-platform Support - Android, iOS, Desktop
- Social Media Integration - Rich previews
- Attribution Parameters - Campaign tracking
Advanced Features
- Apple Ads Token - iOS advertising ID integration
- Firebase Analytics - Uninstall tracking
- Campaign Data - Complete parameter retrieval
- User Data Management - Profile integration
Repository Structure
cordova-sdk-simulator/
├── src/
│ ├── app/
│ │ ├── app.module.ts # SDK initialization
│ │ ├── built-in-events/ # Built-in event tracking
│ │ ├── customs-events/ # Custom event tracking
│ │ ├── deep-linking/ # Deep link handling
│ │ ├── dynamic-link/ # Dynamic link creation
│ │ ├── campaign-data/ # Campaign data retrieval
│ │ └── services/ # Firebase & deep link services
│ └── environments/
│ └── environment.ts # Configuration
├── android/ # Android platform files
├── ios/ # iOS platform files
└── package.json # Dependencies
Quick Start
1. Clone the Repository
git clone https://github.com/ApptroveLabs/cordova-sdk-simulator.git
cd cordova-sdk-simulator
2. Install Dependencies
npm install
3. Configure Environment
Update src/environments/environment.ts
with your Trackier credentials:
export const environment = {
production: false,
trackierSdkKey: 'your-sdk-key-here',
};
4. iOS Setup (macOS only)
cd ios && pod install && cd ..
5. Run the App
# Development server
ionic serve
# Build for Android
ionic capacitor build android
# Build for iOS (macOS only)
ionic capacitor build ios
Implementation Examples
SDK Initialization
private initializeTrackierSDK() {
const key = "your-sdk-key-here";
const trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
// Platform-specific configurations
trackierConfig.setAndroidId("User Android Id 1234567890");
trackierConfig.setFacebookAppId("Your Facebook App id");
this.trackierCordovaPlugin.initializeSDK(trackierConfig).then(() => {
console.log("Trackier SDK initialized successfully.");
// Set Trackier ID as Firebase User Property
this.trackierCordovaPlugin.getTrackierId()
.then(val => this.firebaseAnalytics.setUserProperty("ct_objectId", val));
// Get Apple Ads Token (iOS only)
if (this.platform.is('ios')) {
this.getAppleAdsToken();
}
});
}
Event Tracking
// Built-in event tracking
async submitEvent() {
const trackierEvent = new TrackierEvent('Fy4uC1_FlN'); // ADD_TO_CART
trackierEvent.setRevenue(99.99);
trackierEvent.setCurrency('USD');
trackierEvent.setParam1('product_id');
trackierEvent.setParam2('quantity');
await this.trackierCordovaPlugin.trackEvent(trackierEvent);
}
// Custom event tracking
async submitCustomEvent() {
const trackierEvent = new TrackierEvent(this.eventId);
trackierEvent.setRevenue(this.revenue);
trackierEvent.setCurrency(this.selectedCurrency);
trackierEvent.setCouponCode("SatyamTest10233");
// Set user data
this.trackierCordovaPlugin.setUserId("Satyan!232");
this.trackierCordovaPlugin.setUserEmail("Satyam@gmail.com");
await this.trackierCordovaPlugin.trackEvent(trackierEvent);
}
Deep Link Handling
// Set up deferred deep link callback
private setupDeferredDeeplinkCallback() {
this.trackierCordovaPlugin.setDeferredDeeplinkCallbackListener((uri: string) => {
console.log("Deferred Deeplink Callback received:", uri);
this.deferredDeeplinkService.setDeferredDeeplink(uri);
// Process deep link navigation
if (uri) {
this.handleDeepLink(uri);
}
});
}
// Handle deep link navigation
handleDeepLink(link: string) {
const url = new URL(link);
const productId = url.searchParams.get('product_id');
const quantity = url.searchParams.get('quantity');
if (url.pathname === '/d' && productId && quantity) {
this.router.navigate(['/cake'], {
queryParams: { productId, quantity }
});
}
}
Dynamic Link Creation
async createDynamicLink() {
const dynamicLinkConfig = {
templateId: 'M5Osa2',
link: 'https://testdeeplink',
domainUriPrefix: 'https://trackier59.u9ilnk.me',
deepLinkValue: 'MyMainactivity',
// Platform-specific parameters
androidParameters: {
redirectLink: 'https://play.google.com/store/apps/details?id=com.yourapp'
},
iosParameters: {
redirectLink: 'https://apps.apple.com/app/yourapp/id123456789'
},
// Attribution parameters
attributionParameters: {
channel: 'social',
campaign: 'summer_sale',
mediaSource: 'facebook',
p1: 'param1_value',
p2: 'param2_value'
}
};
const dynamicLink = await this.trackier.createDynamicLink(dynamicLinkConfig);
console.log("Dynamic link created:", dynamicLink);
}
Apple Ads Token Integration
private async getAppleAdsToken() {
try {
if (!this.platform.is('ios')) return;
const trackingResult = await AdvertisingId.requestTracking();
if (trackingResult.value === 'Authorized') {
const advertisingResult = await AdvertisingId.getAdvertisingId();
const token = advertisingResult.id;
if (token) {
this.trackierCordovaPlugin.updateAppleAdsToken(token);
console.log("Apple Ads Token sent to Trackier SDK");
}
}
} catch (error) {
console.error("Error getting Apple Ads Token:", error);
}
}
Firebase Analytics Integration
export class FirebaseAnalyticsService {
async setUserProperty(name: string, value: string): Promise<void> {
try {
if (window.FirebaseAnalytics) {
await window.FirebaseAnalytics.setUserProperty({ name, value });
console.log(`Firebase Analytics: Set user property ${name} = ${value}`);
}
} catch (error) {
console.error('Error setting Firebase user property:', error);
}
}
}
Testing Features
Built-in Events Testing
- Navigate to "Built-in events" from home screen
- Select an event type from dropdown
- Enter revenue amount and select currency
- Add custom parameters (up to 10)
- Submit event and verify in logs
Custom Events Testing
- Navigate to "Customs Events" from home screen
- Enter custom event ID
- Set revenue and currency
- Add parameters as needed
- Submit and verify tracking
Deep Link Testing
- Use test URL:
https://trackier58.u9ilnk.me/d/8X7iwyXsyA
- Navigate to "Deep linking Page"
- Test deep link processing
- Verify parameter extraction and navigation
Dynamic Link Testing
- Navigate to "Dynamic Links"
- Create sample dynamic link
- Test URL resolution
- Verify structured data display
Platform Support
Android
- Deep Link Handling - Intent filters and URL schemes
- Event Tracking - Built-in and custom events
- Dynamic Link Creation - Template-based link generation
- Firebase Analytics - Uninstall tracking integration
- Facebook App ID - Attribution tracking
- Android ID - Device identification
iOS
- Deep Link Handling - URL schemes and universal links
- Event Tracking - Built-in and custom events
- Dynamic Link Creation - Template-based link generation
- Apple Ads Token - Advertising ID integration
- Firebase Analytics - Uninstall tracking integration
Dependencies
Core Dependencies
{
"dependencies": {
"@awesome-cordova-plugins/core": "^6.14.0",
"@capacitor/android": "6.2.0",
"@capacitor/ios": "^7.4.3",
"@ionic/angular": "^8.4.1",
"@capacitor-community/firebase-analytics": "^6.0.0",
"@capacitor-community/advertising-id": "^6.0.0",
"com.trackier.cordova_sdk": "github:trackier/cordova_sdk"
}
}
Android Dependencies
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-analytics:21.5.0'
}
Event Summary
Event Type | Event ID | Location | Trigger |
---|---|---|---|
ADD_TO_CART | Fy4uC1_FlN | built-in-events.page.ts | User selection |
LEVEL_ACHIEVED | 1CFfUn3xEY | built-in-events.page.ts | User selection |
ADD_TO_WISHLIST | AOisVC76YG | built-in-events.page.ts | User selection |
COMPLETE_REGISTRATION | mEqP4aD8dU | built-in-events.page.ts | User selection |
TUTORIAL_COMPLETION | 99VEGvXjN7 | built-in-events.page.ts | User selection |
PURCHASE | Q4YsqBKnzZ | built-in-events.page.ts | User selection |
SUBSCRIBE | B4N_In4cIP | built-in-events.page.ts | User selection |
START_TRIAL | jYHcuyxWUW | built-in-events.page.ts | User selection |
ACHIEVEMENT_UNLOCKED | xTPvxWuNqm | built-in-events.page.ts | User selection |
CONTENT_VIEW | Jwzois1ays | built-in-events.page.ts | User selection |
TRAVEL_BOOKING | yP1-ipVtHV | built-in-events.page.ts | User selection |
SHARE | dxZXGG1qqL | built-in-events.page.ts | User selection |
INVITE | 7lnE3OclNT | built-in-events.page.ts | User selection |
LOGIN | o91gt1Q0PK | built-in-events.page.ts | User selection |
UPDATE | sEQWVHGThl | built-in-events.page.ts | User selection |
Troubleshooting
Common Issues
SDK Not Initializing
- Verify SDK key in environment file
- Check console logs for credential errors
- Ensure proper import statements
Deep Links Not Working
- Verify URL format and parameters
- Check Android manifest intent filters
- Test with provided sample URLs
Events Not Tracking
- Verify event IDs from Trackier panel
- Check network connectivity
- Monitor console logs for errors
iOS Build Issues
- Clean and rebuild:
cd ios && rm -rf build && pod install
- Check Xcode project settings
- Verify iOS deployment target
Apple Ads Token Issues
- Ensure iOS 14+ for tracking authorization
- Check privacy permissions
- Verify advertising ID availability
Firebase Analytics Issues
- Ensure google-services.json is present
- Check Firebase project configuration
- Verify plugin installation
Support
For technical support and questions:
- Support Email: support@trackier.com
- GitHub Issues: Create an issue in the repository
This example app provides comprehensive tracking, deep linking, and dynamic link functionality for Cordova applications using the Trackier SDK, demonstrating best practices for mobile app analytics and attribution with a modern, user-friendly interface.