trackCampaign
The trackCampaign() method tracks online campaigns that bring traffic to your mobile app. To track a campaign, you need to add campaign parameters to each campaign link and then use this method to pass that data. Campaign data is collected with the first tracked screen event.
Syntax
const options = {
visitCustomVariables: { index: { name: 'name', value: 'value' },
customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackCampaign('campaignURL', options);
Parameters
campaignURL (string, required)
The URL you used in your campaign to bring traffic to your mobile app. Valid formats: HTTPS, HTTP and FTP. Example: http://example.com?pk_campaign=Summer_Promo&pk_keyword=banking_app
Note: You can tag campaigns manually or use our Piwik PRO URL builder. For now, only the pk_campaign and pk_keyword work on SDKs, so don’t use any other parameters.
options (object, optional)
Campaign tracking options: an object containing two properties.
customDimensions
An object that specifies custom dimensions.
visitCustomVariables
An object that specifies visit custom variables.
Examples
To pass campaign data from the campaign link http://example.com?pk_campaign=Summer_Promo&pk_keyword=banking_app
:
const options = {
visitCustomVariables: { index: { name: 'name', value: 'value' },
customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackCampaign('http://example.com?pk_campaign=Summer_Promo&pk_keyword=banking_app', options);
Notes
- For now, only the pk_campaign and pk_keyword parameters work on SDKs, so don’t use any other parameters.
- Piwik PRO recognizes the pk_campaign and pk_keyword parameters by default. But if you are having problems tracking your campaigns, make sure these parameters are added in Administration > Sites & apps > Data collection > Campaigns > Campaign parameters. Read more.
- On iOS, the campaign information will be sent to the server with the next analytics event.
Updated 6 days ago