Skip to main content

Getting Campaign Data

The Trackier Cordova SDK provides a set of asynchronous methods to retrieve campaign-related data, such as ad identifiers, campaign names, click IDs, and custom parameters, enabling developers to personalize user experiences and analyze marketing campaign performance. This section outlines how to use these methods to access attribution details in your Cordova or Ionic Native application.

Prerequisites

  • Trackier Cordova SDK installed and initialized in your project
  • A Trackier MMP account with access to the Trackier Panel
  • Cordova 9.0 or later
  • For Ionic Native apps:
    • Ionic CLI and Capacitor
    • @awesome-cordova-plugins/core and trackier plugin configured
  • Basic knowledge of JavaScript, Angular (for Ionic Native), and Cordova development
  • Campaign tracking links set up in the Trackier Panel to generate attributable data

Retrieve Campaign Data

The SDK offers individual methods to fetch specific campaign attributes, such as getAd, getCampaign, and getClickId, which return data asynchronously via promises. These attributes can be used to tailor in-app content, enrich analytics, or optimize marketing strategies.

Steps to Retrieve Campaign Data

  1. Initialize the AppTrove SDK with your SDK key and environment.
  2. Call the relevant campaign data methods (e.g., getTrackierId, getAd, getClickId) using promise-based syntax (then and catch).
  3. Process the returned data, such as logging it to the console, storing it, or using it for personalization.
  4. Optionally, integrate the data with an event by tracking a TrackierEvent to associate campaign details with user actions.
JavaScript Example (Ionic Native)
tab1.page.ts
import { Component } from '@angular/core';
import { TrackierCordovaPlugin, TrackierConfig, TrackierEnvironment, TrackierEvent } from '@awesome-cordova-plugins/trackier/ngx';

@Component({
selector: 'app-tab3',
templateUrl: 'tab3.page.html',
styleUrls: ['tab3.page.scss']
})
export class Tab3Page {
constructor(private trackierCordovaPlugin: TrackierCordovaPlugin) {}

async ngOnInit() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
this.trackierCordovaPlugin.initializeSDK(trackierConfig);

// Retrieve Campaign Data
var trackierEvent = new TrackierEvent("1CFfUn3xEY");
this.trackierCordovaPlugin.getTrackierId().then(val => console.log('===trackierid-: ', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getAd().then(val => console.log('getAd', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getAdID().then(val => console.log('getAdID', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getCampaign().then(val => console.log('getCampaign', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getCampaignID().then(val => console.log('getCampaignID', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getAdSet().then(val => console.log('getAdSet', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getAdSetID().then(val => console.log('getAdSetID', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getChannel().then(val => console.log('getChannel', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getP1().then(val => console.log('getP1', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getP2().then(val => console.log('getP2', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getP3().then(val => console.log('getP3', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getP4().then(val => console.log('getP4', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getP5().then(val => console.log('getP5', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getClickId().then(val => console.log('getClickId', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getDlv().then(val => console.log('getDlv', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getPid().then(val => console.log('getPid', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.getIsRetargeting().then(val => console.log('getIsRetargeting', val)).catch(e => console.log('error: ', e));
this.trackierCordovaPlugin.trackEvent(trackierEvent);
}
}
JavaScript Example (Pure Cordova)
tab1.page.ts
document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
TrackierCordovaPlugin.initializeSDK(trackierConfig);

// Retrieve Campaign Data
var trackierEvent = new TrackierEvent("1CFfUn3xEY");
TrackierCordovaPlugin.getTrackierId().then(val => console.log('===trackierid-: ', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getAd().then(val => console.log('getAd', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getAdID().then(val => console.log('getAdID', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getCampaign().then(val => console.log('getCampaign', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getCampaignID().then(val => console.log('getCampaignID', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getAdSet().then(val => console.log('getAdSet', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getAdSetID().then(val => console.log('getAdSetID', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getChannel().then(val => console.log('getChannel', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getP1().then(val => console.log('getP1', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getP2().then(val => console.log('getP2', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getP3().then(val => console.log('getP3', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getP4().then(val => console.log('getP4', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getP5().then(val => console.log('getP5', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getClickId().then(val => console.log('getClickId', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getDlv().then(val => console.log('getDlv', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getPid().then(val => console.log('getPid', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.getIsRetargeting().then(val => console.log('getIsRetargeting', val)).catch(e => console.log('error: ', e));
TrackierCordovaPlugin.trackEvent(trackierEvent);
}

Available Methods

The following asynchronous methods retrieve specific campaign data attributes:

  • getTrackierId(): Returns the unique Trackier ID for the user.
  • getAd(): Returns the ad name.
  • getAdID(): Returns the ad identifier.
  • getCampaign(): Returns the campaign name.
  • getCampaignID(): Returns the campaign identifier.
  • getAdSet(): Returns the ad set name.
  • getAdSetID(): Returns the ad set identifier.
  • getChannel(): Returns the channel name.
  • getP1() to getP5(): Return custom parameters (P1 to P5).
  • getClickId(): Returns the unique click identifier.
  • getDlv(): Returns the deep link value.
  • getPid(): Returns the partner ID.
  • getIsRetargeting(): Returns a boolean indicating whether the campaign is for retargeting.

Expected Outcome

Each method returns a promise that resolves to the corresponding campaign attribute value, which is logged to the console or can be used for further processing (e.g., personalization, analytics). The data is also accessible in the Trackier Panel for campaign performance analysis.

Best Practices

  • Call After Initialization: Ensure the SDK is initialized before calling campaign data methods to avoid null responses.
  • Handle Errors: Use .catch to manage errors and provide fallback logic for cases where data is unavailable (e.g., organic installs).
  • Test with Campaign Links: Simulate attributed installs using Trackier-generated campaign tracking links to verify data retrieval.
  • Use Development Environment: Test in TrackierEnvironment.Development to avoid affecting production analytics.
  • Integrate with Events: Combine campaign data with TrackierEvent tracking to enrich analytics with attribution details.
  • Store Data Securely: If storing campaign data, encrypt sensitive fields like clickId to comply with privacy regulations.
  • Comply with Privacy Laws: Ensure campaign data usage adheres to GDPR, CCPA, and other privacy regulations, obtaining user consent if required.

Troubleshooting

  • No Campaign Data Returned:
    • Verify the SDK is initialized before calling campaign data methods.
    • Ensure the install was triggered by a Trackier campaign tracking link; organic installs may return null values.
    • Check the Trackier Panel to confirm campaign tracking links are correctly configured.
  • Promise Errors:
    • Confirm each method is called with proper promise handling (.then and .catch).
    • Check console logs for errors related to trackierCordovaPlugin methods.
  • Incorrect Data:
    • Validate campaign setup in the Trackier Panel to ensure expected parameters (e.g., ad, campaignid) are included.
    • Test with multiple campaign links to ensure consistent data retrieval.
  • Ionic Native Issues:
    • Ensure the TrackierCordovaPlugin provider is registered in app.module.ts.
    • Verify the trackier folder is in node_modules/@awesome-cordova-plugins and ionic cap sync was executed.

For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.