Configure CTM on a Subdomain Using AWS CloudFront

CloudFront allows you to load the tracking code through your domain, accelerating delivery and enabling whitelabel support. Follow these steps to run CTM functionality through a subdomain.

Step 1: Create a CloudFront Distribution

  1. Log in to the AWS Console.

  2. In the search bar, type CloudFront and select it.

  3. In the left-hand menu, click Distributions.

  4. Click Create Distribution in the top-right corner.

  5. Leave all settings at their defaults unless specified below.

  6. Select your package. You can start with the Free package.

  7. Enter a name for your distribution.

  8. Set Distribution Type to Single website or app.

Configure Origin

  1. Set Origin Type to Other.

  2. In Custom Origin, enter:

cdn.tctm.co

Add Required Headers

  1. Under Settings, click Customize Origin Settings.

  2. Click Add Header and add the following:

  • Header Name: x-cdn
    Value: cloudfront

  • Header Name: x-act
    Value: your CTM Account ID

Ensure there are no extra spaces when copying and pasting.

Configure Cache Settings

  1. Select Customize Cache Settings.

  2. Set Allowed HTTP Methods to:

GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
  1. Set the following policies:

  • Cache Policy: CachingDisabled

  • Origin Request Policy: AllViewer

  1. Continue to the next page.

  2. Do not enable security. If the option is unavailable, leave the settings at their default.

  3. Click Create Distribution.

Step 2: Create a Second Behavior

  1. Open your distribution.

  2. Click the Behaviors tab.

  3. Click Create Behavior.

Configure Behavior

  1. Set Path Pattern to:

    /*.js
  2. Select your origin from the dropdown.

  3. Set Allowed HTTP Methods to:

    GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
  4. Select Customize Cache Settings and apply:

    • Cache Policy: CachingDisabled

    • Origin Request Policy: AllViewer

  5. Click Create Behavior.

Step 3: Request an SSL Certificate

  1. In the AWS Console, search for Certificate Manager and open it.

  2. Click Request.

  3. Select Request a public certificate and click Next.

  4. Select N. Virginia as the Region in the top-right dropdown.

Add Domain

  1. Enter your subdomain:

    ctm.yourdomain.com

    Example:

    ctm.testing.com
  2. Leave other settings as the default.

  3. Click Request.

Step 4: Add DNS Records for Certificate Validation

  1. Open the certificate you just created.

  2. Locate the CNAME Name and CNAME Value.

  3. Add these records in your DNS provider.

  4. Return to Certificate Manager and wait for the status to change from Pending to Issued.

  5. Refresh the page to check the status.

  6. This process can take 5 to 60 minutes.

Important Notes

  • Some DNS providers automatically append your domain.

  • If your provider does this, remove the domain portion from the CNAME Name before entering it.

  • If your provider requires the full value, enter it exactly as shown.

  • Paste the CNAME Value exactly as provided.

Step 5: Final CloudFront Configuration

  1. Go back to your CloudFront distribution.

  2. Under the General tab, click Edit.

Update Settings

  1. In Alternate Domain Name (CNAME), enter:

    ctm.yourdomain.com
  2. In Custom SSL Certificate, select the certificate you created.

  3. Click Save Changes.

Step 6: Add Subdomain to DNS

  1. In your CloudFront distribution, locate the Distribution Domain Name.
    Example:

    d123example.cloudfront.net
  2. Copy this value.

Create DNS Record

  1. Go to your DNS provider.

  2. Add a new CNAME record:

    • Name: ctm

    • Value: your CloudFront distribution domain

  3. Save the record.

Step 7: Allow for Propagation

  • Changes may take up to one hour to propagate.

  • If you see a "Not Secured" message in your browser, propagation is still in progress.

Step 8: Run Validation Tests

Open the following URLs in your browser:

  1. https://ctm.yourdomain.com/t.js

    Expected result: JavaScript code is displayed.

  2. https://ctm.yourdomain.com/x.json

    Expected result: No errors.

Step 9: Update Your Tracking Code

Once validation is successful, update your website tracking script:

<script src="https://ctm.yourdomain.com/t.js"></script>
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.