iOS Custom Proxy Domain
Custom Proxy Domain
A custom proxy domain allows you to proxy all events raised from the CleverTap SDK through your required domain. If you want to use your application server, use a proxy domain to handle and/or relay CleverTap events. We provide custom domain support for Push Impression event handling.
Why is it useful?
Using a custom proxy domain has the following benefits:
- Use your own domain to collect data.
- Have fine control over filtering, auditing, and/or cleaning data before sending it to CleverTap.
- Turn event collection on or off across all platforms quickly.
- If you want to use your own application server, you can use a proxy domain to handle and/or relay CleverTap events.
You must have a domain and access to DNS site settings to set up the proxy domain. To create an AWS Certificate and CloudFront distribution for the proxy domain, perform the steps listed in the following sections, and then integrate CleverTap SDK with your proxy domain configuration.
AWS Certificate Manager
To create a certificate using ACM in the required region:
- Go to Certificate Manager in AWS.
- Click Request Certificate and select Request a public certificate.
- Add the proxy domain name that you want to use. This proxy domain name relays events to CleverTap's origin domain. For example, subdomain.domain.com.
- Select a validation method based on your domain account permission.
- After review, confirm and request the certificate.
- Copy the CNAME record from AWS Certificate Manager (ACM) details to add it to your domain registrar settings.
- Add the CNAME record in DNS Settings as shown below:
The ACM Validation status should update from Pending to Success
in some time. This certificate is used for creating CloudFront distribution.
AWS CloudFront Distribution
Origin
- Enter Origin Domain: eu1.clevertap-prod.com.
- Select Protocol: HTTPS.
Default Cache Behaviour:
- Select Redirect HTTP to HTTPS as the Viewer protocol policy.
- Select GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE as the Allowed HTTP methods.
- Under Cache key and origin requests, select Cache policy and origin request policy (recommended) option and select CachingOptimized from the list.
Settings
-
Add proxy name in Alternate domain name (CNAME) - optional: analytics.sdktesting.xyz. This is the same proxy used earlier to create the AWS certificate.
-
Select the certificate created earlier in Custom SSL certificate - optional.
- Select the recommended option under Security policy.
- Keep the other settings at default selection and click Create Distribution.
- Add another CNAME in DNS Settings to point your subdomain (analytics in this case) to the CloudFront distribution, as shown in the following image:
- After the CloudFront distribution is deployed, enter the proxy domain in the browser address to check if the settings are working correctly.
Integrate CleverTap to use Proxy Domain
Using Autointegrate
API
Autointegrate
API- Add your CleverTap credentials in the Info.plist file of your application.
- Insert the Account ID and Account Token values from your CleverTap account against the
CleverTapAccountID
andCleverTapToken
keys. - Add the
CleverTapProxyDomain
key with the proxy domain value for handling events through the custom proxy domain. - Add the
CleverTapSpikyProxyDomain
key with proxy domain value for handling push impression events.
- Import the CleverTap SDK in your AppDelegate file and call CleverTap's
autoIntegrate
method in thedidFinishLaunchingWithOptions:
method.
CleverTap.autoIntegrate()
- Use CleverTap's
sharedInstance
to log events.
CleverTap.sharedInstance()?.recordEvent("Product viewed")
Using setCredentials
API
setCredentials
API- Import the CleverTap SDK and call either the
setCredentialsWithAccountID:token:proxyDomain:
method or thesetCredentialsWithAccountID:token:proxyDomain:spikyProxyDomain:
method.
CleverTap.setCredentialsWithAccountID(accountID: ACCOUNT_ID, token: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz")
CleverTap.setCredentialsWithAccountID(accountID: ACCOUNT_ID, token: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz", spikyProxyDomain: "spiky-analytics.sdktesting.xyz")
- Use CleverTap's
sharedInstance
to log events.
CleverTap.sharedInstance()?.recordEvent("Product viewed")
Create CleverTap's Additional Instance
- Call
CleverTapInstanceConfig
constructor with either of the following APIs:
let ctConfig = CleverTapInstanceConfig(accountId: ACCOUNT_ID, accountToken: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz")
let ctConfig = CleverTapInstanceConfig(accountId: ACCOUNT_ID, accountToken: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz", spikyProxyDomain: "spiky-analytics.sdktesting.xyz")
- Start the CleverTap instance by calling the
CleverTap.instance(with:)
method with theCleverTapInstanceConfig
object you created earlier.
let cleverTapProxyInstance = CleverTap.instance(with: ctConfig)
- Use this instance to log events.
cleverTapProxyInstance.recordEvent("Product viewed")
Debug and Test
After integration, the logged events are available on the CleverTap dashboard. Use CleverTapInstanceConfig's logLevel instance variable or CleverTap.setDebugLevel(1)
to debug requests and response.
Updated about 1 year ago