Skip to content

Latest commit

 

History

History
141 lines (121 loc) · 6.68 KB

CustomDomainSetup.md

File metadata and controls

141 lines (121 loc) · 6.68 KB

🔖 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

    Request Certificate

  • 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

    Add the domain name

  • Select a validation method as per your domain account permission

    Select validation method

  • After review, Confirm and request the certificate
  • Copy the CNAME record from ACM details to add it in your domain registrar settings

    CNAME record details

  • Add the CNAME Record in DNS Settings as shown below

    Add CNAME in DNS

  • In few minutes, ACM Validation status should update from Pending to Success

We will use this certificate while creating CloudFront distribution.

📦 AWS CloudFront Distribution

  1. Origin:
    1. Enter Origin Domain: eu1.clevertap-prod.com
    2. Select Protocol: HTTPS
    3.  

  2. Default cache behaviour:
    1. Select Redirect HTTP to HTTPS in Viewer protocol policy
    2. Select GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE in Allowed HTTP methods
    3.  

    4. Under Cache key and origin requests, select Cache policy and origin request policy (recommended) option and choose CachingOptimized from dropdown
    5.  

  3. Settings:
    1. 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.
    2. Choose the earlier created certificate in Custom SSL certificate - optional
    3.  

    4. Select the recommended option under Security policy
    5.  

  4. Keep rest of the settings as it is and click Create Distribution
  5.  

  6. Add another CNAME in DNS Settings to point your subdomain(analytics in this case) to cloudfront distribution as shown
  7.  

  8. Once CloudFront distribution is deployed, hit proxy domain on browser to check if settings are up and running.

👩‍💻Integrating CleverTap to use proxy domain

🛠 Using 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 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")

🛠 Using setCredentials API

  • Import CleverTapSDK and call either setCredentialsWithAccountID:token:proxyDomain: method or setCredentialsWithAccountID: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")

🛠 Creating additional CleverTap's instance

  • 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")

⚙️ 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.