I have a landing page in Marketing Cloud which I populate dynamically depending on variables in the url.

The landing page is accessed from a link in an email. Purpose is to get people to sign up and join a SF campaign.

The id of the campaign sits in a parameter in the url.

I would like to retrieve the Campaign name from Salesforce. Do you know how to do that in ampscript?


If you have Salesforce API calls to burn, you would create a landing page in Cloud Pages from code and use the AMPScript QueryParameter function to retrieve the ID of the Campaign from the URL to the landing page:

SET @SFCampaignID = QueryParameter("cid")

You'd then use the AMPScript function RetrieveSalesforceObjects to get the name of the Campaign:

/* RetrieveSalesforceObjects returns a rowset */
SET @Campaigns = RetrieveSalesforceObjects("Campaign", "Name", "Id", "=", @SFCampaignID)

/# Take the name field from the first row of @Campaigns */
SET @CampaignName = Field(Row(@Campaigns,1),"Name")

Finally, you'd spit out the name of the campaign on your page:

Thanks for signing up for %%=v(@CampaignName)=%%

Pragmatically, I'd opt for importing the Campaigns object into SFMC either use imports or Data Stream and using LookupRows to get the data that's been staged in SFMC Data Extensions. You'd end up with a slightly faster page load and not needlessly waste CRM API calls/quota.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.