AMPScript Social Links

Need to share content in your Salesforce Marketing Cloud email? Here are some methods of building social sharing links using AMPScript inside the Salesforce Marketing Cloud platform. The link structure can be used in plain ole HTML and JavaScript also.


var @fbTitle, @fbImage, @fbSummary, @fbURL, @fbPostURL
set @fbTitle = "this is the title"
set @fbImage = ""
set @fbSummary = "whee whoa whoops"
set @fbURL = ""

set @fbPostURL = concat("", urlencode(@fbTitle,1),"&p%5Burl%5D=",urlencode(@fbURL,1),"&p%5Bimages%5D%5B0%5D=",urlencode(@fbImage,1),"&p%5Bsummary%5D=",urlencode(@fbSummary,1))

Post to Facebook

NOTE: The link doesn’t work on mobile devices. Let me know in the comments if you find a good solution for Facebook sharing on mobile without JavaScript.


var @twText, @twPostURL
set @twText = "whee whoa whoops"
set @twPostURL = concat("",urlencode(@twText,1))

Tweet it


var @pinURL, @pinImageURL, @pinDesc, @pin
set @pinURL = ""
set @pinImageURL = ""
set @pinDesc = "whee whoa whoops"
set @pin = concat("",urlencode(@pinURL,1),"&media=",urlencode(@pinImageURL,1),"&description=",urlencode(@pinDesc,1))

pin it

Google Plus

var @gplusURL, @gplusLang
set @gplusURL = ""
set @gplusLang = "en-US"
set @gplusLink = concat("",urlencode(@gplusURL,1),"&hl=",urlencode(@gplusLang,1))


For further reference:
Google Developer – Share links
Google Developer – Available languages

Leave a Reply

2 Comments on "AMPScript Social Links"

Notify of
Sort by:   newest | oldest | most voted
Vic Dinovici

I used to think the same and use concatenation to build the sharing links until after so many frequent updates from these social websites I gave up an use the URLs they provide – each social website is providing the snippet to use into your code so why not just using it?