## 🔖 Overview 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. ## 📄 AWS Certificate Manager 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. ## 📦 AWS CloudFront Distribution
- Import CleverTapSDK in your AppDelegate file and call CleverTap's autoIntegrate in the ```didFinishLaunchingWithOptions:``` method. ```swift CleverTap.autoIntegrate() ``` - Use CleverTap's sharedInstance to log events. ```swift CleverTap.sharedInstance()?.recordEvent("Product viewed") ``` ### 🛠 Using setCredentials API - Import CleverTapSDK and call either ```setCredentialsWithAccountID:token:proxyDomain:``` method or ```setCredentialsWithAccountID:token:proxyDomain:spikyProxyDomain:``` method. ```swift CleverTap.setCredentialsWithAccountID(accountID: ACCOUNT_ID, token: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz") ``` ```swift CleverTap.setCredentialsWithAccountID(accountID: ACCOUNT_ID, token: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz", spikyProxyDomain: "spiky-analytics.sdktesting.xyz") ``` - Use CleverTap's sharedInstance to log events. ```swift CleverTap.sharedInstance()?.recordEvent("Product viewed") ``` ### 🛠 Creating additional CleverTap's instance - Create CleverTapInstanceConfig with either of the following APIs. ```swift let ctConfig = CleverTapInstanceConfig(accountId: ACCOUNT_ID, accountToken: ACCOUNT_TOKEN, proxyDomain: "analytics.sdktesting.xyz") ``` ```swift 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. ```swift let cleverTapProxyInstance = CleverTap.instance(with: ctConfig) ``` - Use the instance created using above steps to log events. ```swift cleverTapProxyInstance.recordEvent("Product viewed") ``` ### ⚙️ Debug and Test 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.