Developers
Ad-blocking technologies sometimes block mParticle tags and event collection endpoints. To prevent blocking and ensure maximum data collection, configure a first-party domain for event collection, and use it instead of the SDK default mparticle.com
domain.
To prevent this blocked HTTP traffic, create a custom subdomain and point that DNS record to mParticle. Traffic is less likely to be blocked because the domain used for mParticle traffic matches the root domain used in your app.
Use this process to create a custom subdomain and point the DNS record to mParticle:
mp.mydomain.com
or mparticle.mydomain.com
. To contact mParticle, visit the mParticle Support site and submit a request.mydomain.com
in this example) has been configured previously, Fastly will need to obtain permission from the account owner or authorized point of contact prior to allowing mParticle to complete provisioning. In this case, an additional TXT DNS record will need to be created. Further details will be provided by mParticle at such time. MParticleOptions *options = [MParticleOptions optionsWithKey:@"REPLACE WITH APP KEY" secret:@"REPLACE WITH APP SECRET"];
options.logLevel = MPILogLevelDebug;
MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];
// maps mp.example.com/config/v4 to config2.mparticle.com/v4
networkOptions.configHost = @"mp.example.com/config/v4";
networkOptions.overridesConfigSubdirectory = YES;
// maps mp.example.com/nativeevents/v2 to nativesdks.mparticle.com/v2
networkOptions.eventsHost = @"mp.example.com/nativeevents/v2";
networkOptions.overridesEventsSubdirectory = YES;
// maps mp.example.com/identity/v1 to identity.mparticle.com/v1
networkOptions.identityHost = @"mp.example.com/identity/v1";
networkOptions.overridesIdentitySubdirectory = YES;
// maps mp.example.com/nativeevents/v1/identity to nativesdks.mparticle.com/v1/identity
networkOptions.aliasHost = @"mp.example.com/nativeevents/v1/identity";
networkOptions.overridesAliasSubdirectory = YES;
// The Godaddy and LetsEncrypt root certificates that mParticle uses are already included in
// the SDK, so the following lines are only needed if you are using your own certificate provider.
networkOptions.certificates = @[ @"your root certificate" ];
options.networkOptions = networkOptions;
[[MParticle sharedInstance] startWithOptions:options];
let options = MParticleOptions(key: "REPLACE WITH APP KEY", secret: "REPLACE WITH APP SECRET")
options.logLevel = .verbose
let networkOptions = MPNetworkOptions()
// maps mp.example.com/config/v4 to config2.mparticle.com/v4
networkOptions.configHost = "mp.example.com/config/v4"
networkOptions.overridesConfigSubdirectory = true
// maps mp.example.com/nativeevents/v2 to nativesdks.mparticle.com/v2
networkOptions.eventsHost = "mp.example.com/nativeevents/v2"
networkOptions.overridesEventsSubdirectory = true
// maps mp.example.com/identity/v1 to identity.mparticle.com/v1
networkOptions.identityHost = "mp.example.com/identity/v1"
networkOptions.overridesIdentitySubdirectory = true
// maps mp.example.com/nativeevents/v1/identity to nativesdks.mparticle.com/v1/identity
networkOptions.aliasHost = "mp.example.com/nativeevents/v1/identity"
networkOptions.overridesAliasSubdirectory = true
// The Godaddy and LetsEncrypt root certificates that mParticle uses are already included in
// the SDK, so the following lines are only needed if you are using your own certificate provider.
let rootCertificate = Data(base64Encoded: "your root certificate")
if let rootCertificate = rootCertificate {
networkOptions.certificates = [rootCertificate]
}
options.networkOptions = networkOptions
MParticle.sharedInstance().start(with: options)
Was this page helpful?