Skip to main content

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
  • 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);
}
// 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 }
});
}
}
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

  1. Navigate to "Built-in events" from home screen
  2. Select an event type from dropdown
  3. Enter revenue amount and select currency
  4. Add custom parameters (up to 10)
  5. Submit event and verify in logs

Custom Events Testing

  1. Navigate to "Customs Events" from home screen
  2. Enter custom event ID
  3. Set revenue and currency
  4. Add parameters as needed
  5. Submit and verify tracking
  1. Use test URL: https://trackier58.u9ilnk.me/d/8X7iwyXsyA
  2. Navigate to "Deep linking Page"
  3. Test deep link processing
  4. Verify parameter extraction and navigation
  1. Navigate to "Dynamic Links"
  2. Create sample dynamic link
  3. Test URL resolution
  4. 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 TypeEvent IDLocationTrigger
ADD_TO_CARTFy4uC1_FlNbuilt-in-events.page.tsUser selection
LEVEL_ACHIEVED1CFfUn3xEYbuilt-in-events.page.tsUser selection
ADD_TO_WISHLISTAOisVC76YGbuilt-in-events.page.tsUser selection
COMPLETE_REGISTRATIONmEqP4aD8dUbuilt-in-events.page.tsUser selection
TUTORIAL_COMPLETION99VEGvXjN7built-in-events.page.tsUser selection
PURCHASEQ4YsqBKnzZbuilt-in-events.page.tsUser selection
SUBSCRIBEB4N_In4cIPbuilt-in-events.page.tsUser selection
START_TRIALjYHcuyxWUWbuilt-in-events.page.tsUser selection
ACHIEVEMENT_UNLOCKEDxTPvxWuNqmbuilt-in-events.page.tsUser selection
CONTENT_VIEWJwzois1aysbuilt-in-events.page.tsUser selection
TRAVEL_BOOKINGyP1-ipVtHVbuilt-in-events.page.tsUser selection
SHAREdxZXGG1qqLbuilt-in-events.page.tsUser selection
INVITE7lnE3OclNTbuilt-in-events.page.tsUser selection
LOGINo91gt1Q0PKbuilt-in-events.page.tsUser selection
UPDATEsEQWVHGThlbuilt-in-events.page.tsUser 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:


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.