Custom proxy domain allows you to proxy all events raised from the CleverTap SDK through your required domain. If you want to use your own application server, then use a proxy domain to handle and/or relay CleverTap events. Custom domain support for Push Impression event handling is provided.
You will need a domain and access to DNS site settings to setup the proxy domain. Follow these steps to create AWS Certificate, CloudFront distribution for the proxy domain and then integrate CleverTap SDK with proxy domain configuration.
To create a certificate using ACM in required region:
- Go to Certificate Manager in AWS
- Click on Request Certificate and select Request a public certificate option
- Add the proxy domain name you want to use. This proxy domain name will be used to relay events to CleverTap's origin domain. Eg: subdomain.domain.com
- Select a validation method as per your domain account permission
- After review, Confirm and request the certificate
- Copy the CNAME record from ACM details to add it in your domain registrar settings
- Add the CNAME Record in DNS Settings as shown below
- In few minutes, ACM Validation status should update from Pending to Success
We will use this certificate while creating CloudFront distribution.
- Origin:
- Default cache behaviour:
- Select Redirect HTTP to HTTPS in Viewer protocol policy
- Select GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE in Allowed HTTP methods
- Under Cache key and origin requests, select Cache policy and origin request policy (recommended) option and choose CachingOptimized from dropdown
- Settings:
- Add proxy name in Alternate domain name (CNAME): analytics.sdktesting.xyz. This is the same proxy which was earlier used to create the AWS certificate.
- Choose the earlier created certificate in Custom SSL certificate - optional
- Select the recommended option under Security policy
- Keep rest of the settings as it is and click Create Distribution
- Add another CNAME in DNS Settings to point your subdomain(analytics in this case) to cloudfront distribution as shown
- Once CloudFront distribution is deployed, hit proxy domain on browser to check if settings are up and running.
- 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 keys CleverTapAccountID and CleverTapToken.
Add CleverTapProxyDomain key with proxy domain value for handling events through custom proxy domain.
Add CleverTapSpikyProxyDomain key with proxy domain value for handling push impression events.
- Import CleverTapSDK in your AppDelegate file and call CleverTap's autoIntegrate in the
didFinishLaunchingWithOptions:
method.
CleverTap.autoIntegrate()
- Use CleverTap's sharedInstance to log events.
CleverTap.sharedInstance()?.recordEvent("Product viewed")
- Import CleverTapSDK and call either
setCredentialsWithAccountID:token:proxyDomain:
method orsetCredentialsWithAccountID: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 CleverTapInstanceConfig 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")
- Instantiate the CleverTap instance by calling CleverTap.instance(with:) method with the CleverTapInstanceConfig object you created.
let cleverTapProxyInstance = CleverTap.instance(with: ctConfig)
- Use the instance created using above steps to log events.
cleverTapProxyInstance.recordEvent("Product viewed")
After integration, you should be able to see logged events on CleverTap dashboard. You could also use CleverTapInstanceConfig's logLevel or CleverTap.setDebugLevel(1)
to debug requests and response.