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.

Facebook

%%[
var @fbTitle, @fbImage, @fbSummary, @fbURL, @fbPostURL
set @fbTitle = "this is the title"
set @fbImage = "https://www.google.com/images/srpr/logo3w.png"
set @fbSummary = "whee whoa whoops"
set @fbURL = "https://sprignaturemoves.com/"

set @fbPostURL = concat("https://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=", 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 https://www.facebook.com/sharer.php 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.

Twitter

%%[
var @twText, @twPostURL
set @twText = "whee whoa whoops https://sprignaturemoves.com/"
set @twPostURL = concat("https://twitter.com/intent/tweet?source=webclient&text=",urlencode(@twText,1))
]%%

Tweet it

Pinterest

%%[
var @pinURL, @pinImageURL, @pinDesc, @pin
set @pinURL = "https://sprignaturemoves.com/"
set @pinImageURL = "https://www.google.com/images/srpr/logo3w.png"
set @pinDesc = "whee whoa whoops"
set @pin = concat("http://pinterest.com/pin/create/button/?url=",urlencode(@pinURL,1),"&media=",urlencode(@pinImageURL,1),"&description=",urlencode(@pinDesc,1))
]%%

pin it

Google Plus

%%[
var @gplusURL, @gplusLang
set @gplusURL = "https://sprignaturemoves.com/"
set @gplusLang = "en-US"
set @gplusLink = concat("https://plus.google.com/share?url=",urlencode(@gplusURL,1),"&hl=",urlencode(@gplusLang,1))
]%%

[+1]

For further reference:
concat
urlencode
redirectto
Google Developer – Share links
Google Developer – Available languages

Leave a Reply

2 Comments on "AMPScript Social Links"

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

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?

wpDiscuz