In today's digital marketing landscape, tracking the performance of marketing campaigns is crucial to understanding their effectiveness and making data-driven decisions. One popular way to track these campaigns is through the use of UTM parameters, which allow marketers to monitor how specific sources, mediums, and content contribute to their overall results. However, adding UTM parameters to URLs can make them lengthy and unattractive, especially when used in SMS messages where character limits and readability are important factors. To overcome this issue, marketers can use link shortening services like to create shorter, branded URLs with embedded UTM tracking parameters.

In the following guide, we will demonstrate how to integrate with Salesforce Marketing Cloud (SFMC) to generate shortened, tracked URLs for use in SMS messages.


Create a new Content Block in SFMC and add the following script:

<script runat="server">
Platform.Load("core", "1");
var url = '';
var contentType = 'application/json';
var data = {
   "allowDuplicates": false,
   "domain": "",
   "originalURL": Variable.GetValue("@FINALURL")
var payload = Stringify(data);
var headerNames = ["Accept", "Authorization"];
var headerValues = ["application/json", "API_KEY_HERE"];
var result = HTTP.Post(url, contentType, payload, headerNames, headerValues);

var resp = Platform.Function.ParseJSON(String(result.Response));

Variable.SetValue("@SHORTCODE", resp.path);


Replace "API_KEY_HERE" with your API key.

In the SMS message content, include the following AMPScript code:

var @shortTag, @shortTag2, @shortTag3, @campaign, @content, @url, @finalUrl
SET @url = ""
SET @content = "EXAMPLE"
SET @shortTag = "TAG1"
SET @shortTag2 = "TAG2"
SET @shortTag3 = "TAG3"

SET @finalUrl = CONCAT(@Url,"?utm_medium=sms&utm_source=SMS&utm_campaign=",@campaign,"&utm_content=",@content)

Replace 'BLOCK_ID_HERE' with the Content Block ID of the Content Block you created in step 1.

This will insert the shortened link with appropriate UTM parameters into your SMS message. Ensure that you have configured your API key, and that you are using the correct domain name for your shortened links.


By integrating with SFMC, marketers can easily create shortened URLs with embedded UTM tracking parameters for their SMS campaigns. This approach not only preserves the character limit and readability of the SMS messages, but also ensures that each click on the link can be accurately tracked and attributed to specific campaign elements. In turn, this data-driven approach enables marketers to optimise their campaigns and make better-informed decisions about their marketing strategies.


SSJS, Shortio, Marketing Cloud, AMPscript