Last active
May 6, 2023 14:38
-
-
Save leto96/991bb33494d96d5dd0ed39e7d90d3ac3 to your computer and use it in GitHub Desktop.
Create Dynamic links using Bit.ly API in Marketing Cloud SMS Send, with AMPScript and Guide Template Language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[ | |
var @cloudpage, @link, @param, @bitlyPage, @contentType, @content, | |
@bitlyToken, @additionalHeaderName, @additionalHeaderValue, @request, @response, | |
@message | |
set @bitlyToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX' // Your bitly Token | |
set @bitlyPage = 'https://api-ssl.bitly.com/v4/bitlinks' | |
set @contentType = 'application/json' | |
set @additionalHeaderName = 'Authorization' | |
set @additionalHeaderValue = concat('Bearer ', @bitlyToken) | |
set @param = AttributeValue('Id'); // Or Any Attribute | |
set @cloudpage = 'https://yourdomain.com/something' | |
set @link = concat(@cloudpage, '?yourparam=', @param) | |
set @content = concat('{"long_url": "',@link,'"}') | |
set @request = HTTPPost(@bitlyPage, @contentType, @content, @response, | |
@additionalHeaderName, @additionalHeaderValue) | |
set @message = 'Hello, this is my link :' | |
]%%%%=v(@message)=%%{{.datasource response type=variable}}{{.data}}{ "target" : "@response" }{{/data}}{{link}}{{/datasource}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment