Runtime verified Test scripts included

Syntax

GetSocialPublishURLByName(socialNetworkName, countryCode, contentRegion[, socialNetworkParamKey1, socialNetworkParamValue1, ...])  →  string

Parameters

Name Type Required Description
socialNetworkName string Yes Name of the target social network
countryCode string Yes ISO country code
contentRegion string Yes Name of the predefined content region to share
socialNetworkParamKey1 string No Key of a parameter passed to the social network
socialNetworkParamValue1 string No Value paired with the preceding key

Further key/value pairs can be appended, so there is no upper bound on the argument count.

Example

%%[
  VAR @share
  SET @share = GetSocialPublishURLByName("Facebook", "US", "Shared content region 1")
]%%
%%=v(@share)=%%

Renders a bare Social Forward link such as http://pages.S7.exacttarget.com/Publish.aspx?qs=ABB7InYiOjEsImQiOjQ5NjR9... — a plain URL with no anchor tag around it.

Because the return is only the URL, wrap it in your own anchor and append tracking parameters as extra key/value pairs:

%%[
  VAR @share
  SET @share = GetSocialPublishURLByName("Facebook", "US", "Shared content region 1", "utm_source", "amp")
]%%
<a href="%%=v(@share)=%%">Share on Facebook</a>

Return value

string — a Social Forward publish URL pointing at the pages.S7.exacttarget.com/Publish.aspx endpoint with a signed qs query string.

The URL is opaque and session-specific, so there is no closed set of sentinel values to test for; the only stable check is that the value is non-empty.

Behaviour

The return is a bare URL, not markup. A valid call renders a plain http://pages.S7.exacttarget.com/Publish.aspx?qs=... string with no surrounding <a> tag, so the caller supplies the anchor.

Appended key/value pairs are accepted. Passing an extra pair such as "utm_source", "amp" was accepted and lengthened the signed query string.

An empty content region aborts the page. GetSocialPublishURLByName("Facebook", "US", "") returns HTTP 422 and discards the output rendered before it, so guard the region name before calling.

An unknown network name aborts the page. GetSocialPublishURLByName("NotARealNetwork", "US", "Shared content region 1") also returns HTTP 422, so the network name must be one the feature recognises.

Show test script
%%[
  VAR @b
  SET @b = RequestParameter("b")

  /* safe call: returns a Social Forward publish URL */
  IF @b == "safe" THEN
    OutputLine(Concat("GetSocialPublishURLByName(Facebook,US,region)=[", GetSocialPublishURLByName("Facebook", "US", "Shared content region 1"), "]"))
  ENDIF

  /* an appended key/value pair is accepted (variadic) */
  IF @b == "param" THEN
    OutputLine(Concat("GetSocialPublishURLByName(...,k,v)=[", GetSocialPublishURLByName("Facebook", "US", "Shared content region 1", "utm_source", "amp"), "]"))
  ENDIF

  /* an empty content region aborts the page: the start marker never renders */
  IF @b == "empty" THEN
    OutputLine(Concat("empty start"))
    OutputLine(Concat("GetSocialPublishURLByName(Facebook,US,'')=[", GetSocialPublishURLByName("Facebook", "US", ""), "]"))
    OutputLine(Concat("empty done"))
  ENDIF

  /* an unknown network name aborts the page too */
  IF @b == "bad" THEN
    OutputLine(Concat("bad start"))
    OutputLine(Concat("GetSocialPublishURLByName(bad,US,region)=[", GetSocialPublishURLByName("NotARealNetwork", "US", "Shared content region 1"), "]"))
    OutputLine(Concat("bad done"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next No

See also