Integration between SFMC and Short.io

Short.io provides shortening links services using brand domain and helps businesses engage a new audience and increase brand recognition. It provides businesses with all benefits of link shortening through APIs. Short.io (formerly short.cm) API usage requires API keys. 

One can use this Link Shortening service with marketing tool like Salesforce Marketing Cloud or Adobe Campaign using service side javascript (SSJS) quiet easily.

Below is the sample code snippet to shorten the personalized URL using Cloud pages within SFMC:

%%[
VAR @SUCCESS, @SHORTCODE
SET @SUCCESS = 1
IF (@SUCCESS == 1) THEN ]%%
<script runat=server>
Platform.Load("core", "1");

var SHORTIO_URL = 'https://api.short.io/links';
var SHORTIO_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXX';

var BRAND_DOMAIN = 'MYDOMAIN.XYZ.COM';

var finalUrl 	= Request.GetQueryStringParameter("url");
var cid 	= Request.GetQueryStringParameter("cid");

var contentType = 'application/json';
var data = {
   "tags": [cid],
   "allowDuplicates": False,
   "domain": BRAND_DOMAIN,
   "originalURL": finalUrl
}
var payload = Stringify(data);
var headerNames = ["Accept", "Authorization"];
var headerValues = ["application/json", SHORTIO_API_KEY];
var result = HTTP.Post(SHORTIO_URL, contentType, payload, headerNames, headerValues);
var resp = Platform.Function.ParseJSON(String(result.Response));
  Write();
Variable.SetValue("@SHORTCODE", resp.path);
</script>
%%[ SET @SUCCESS = 2
ENDIF]%%
https://MYDOMAIN.XYZ.COM/%%=v(@SHORTCODE)=%%

References:

https://short.io/features/api

###

(Visited 75 times, 1 visits today)