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
Log in to the AWS Console.
In the search bar, type CloudFront and select it.
In the left-hand menu, click Distributions.
Click Create Distribution in the top-right corner.
Leave all settings at their defaults unless specified below.
Select your package. You can start with the Free package.
Enter a name for your distribution.
Set Distribution Type to Single website or app.
Configure Origin
Set Origin Type to Other.
In Custom Origin, enter:
cdn.tctm.co
Add Required Headers
Under Settings, click Customize Origin Settings.
Click Add Header and add the following:
Header Name:
x-cdn
Value:cloudfrontHeader Name:
x-act
Value: your CTM Account ID
Ensure there are no extra spaces when copying and pasting.
Configure Cache Settings
Select Customize Cache Settings.
Set Allowed HTTP Methods to:
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
Set the following policies:
Cache Policy: CachingDisabled
Origin Request Policy: AllViewer
Continue to the next page.
Do not enable security. If the option is unavailable, leave the settings at their default.
Click Create Distribution.
Step 2: Create a Second Behavior
Open your distribution.
Click the Behaviors tab.
Click Create Behavior.
Configure Behavior
Set Path Pattern to:
/*.js
Select your origin from the dropdown.
Set Allowed HTTP Methods to:
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
Select Customize Cache Settings and apply:
Cache Policy: CachingDisabled
Origin Request Policy: AllViewer
Click Create Behavior.
Step 3: Request an SSL Certificate
In the AWS Console, search for Certificate Manager and open it.
Click Request.
Select Request a public certificate and click Next.
Select N. Virginia as the Region in the top-right dropdown.
Add Domain
Enter your subdomain:
ctm.yourdomain.com
Example:
ctm.testing.com
Leave other settings as the default.
Click Request.
Step 4: Add DNS Records for Certificate Validation
Open the certificate you just created.
Locate the CNAME Name and CNAME Value.
Add these records in your DNS provider.
Return to Certificate Manager and wait for the status to change from Pending to Issued.
Refresh the page to check the status.
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
Go back to your CloudFront distribution.
Under the General tab, click Edit.
Update Settings
In Alternate Domain Name (CNAME), enter:
ctm.yourdomain.com
In Custom SSL Certificate, select the certificate you created.
Click Save Changes.
Step 6: Add Subdomain to DNS
In your CloudFront distribution, locate the Distribution Domain Name.
Example:d123example.cloudfront.net
Copy this value.
Create DNS Record
Go to your DNS provider.
Add a new CNAME record:
Name:
ctmValue: your CloudFront distribution domain
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:
https://ctm.yourdomain.com/t.js
Expected result: JavaScript code is displayed.
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>
Comments
Article is closed for comments.