AmpScript: Proper Use of CloudPagesURL and How to Retrieve Variables

Published by: Santiago Tabuenca on November 2, 2023
 Santiago Tabuenca

In Salesforce Marketing Cloud, CloudPageURL is an essential function that allows you to set your CloudPages as destinations.


 

This function is commonly used in emails to direct subscribers to specific pages. This article will guide you through the use of CloudPageURL, its structure, and how to combine it with other functions to ensure it works seamlessly in Marketing Cloud.

 

Structure of the CloudPageURL Function

The CloudPageURL function is quite simple and takes only one mandatory parameter: the ID of the page you want to link to. This ID can be found in the parameters of each CloudPage.

It also has optional fields for passing multiple pairs of variables and values.

 

Here is the basic structure of the function:

 

<a href="%%=CloudPagesURL(1234,'variable1','valor1','variable2','valor2',...)=%%">Visitar a>

This code will generate a link to your CloudPage with the ID 1234.

You can add as many variable-value pairs as you like, making it easy to customize your links.


Using RedirectTo and Concat

 

When you use CloudPageURL in your emails, keep in mind that this function automatically adds certain parameters to the URLs, such as tracking parameters. To prevent broken links, it's recommended to combine CloudPageURL with the RedirectTo and Concat functions. This creates a proper URL with all the additional parameters and the correct separator:

 

<a href="%%=RedirectTo(CONCAT(CloudPagesURL(1234),'?tema=marketing'))=%%">Visitar Página</a>

 

This way, you ensure that the generated links work correctly even in emails.


Passing Parameters

 

CloudPageURL also makes it easy to include parameters in your links. You can follow the page ID with one or more key-value pairs separated by commas to pass parameters:

 

<a href="%%=RedirectTo(CONCAT(CloudPagesURL(1234,'color','rojo')))=%%">Visitar Página</a>

 


A significant benefit of this function is that it automatically encodes all parameters, eliminating the need to encode them separately using Base64Encode or other methods.

 

How to Retrieve Variables on the Destination Page

 

When using CloudPageURL, you can pass three types of variables to your destination page:

 

Sendable Data Extension Variables

If you've included specific variables in your sendable Data Extension, you can retrieve them on your destination page using AMPscript. Let's say you have a variable called "NombreProducto" in your Data Extension; you can retrieve it as follows:

 


%%[ SET @NombreProducto = AttributeValue('NombreProducto') ]%%

 


Personalization String Variables in Marketing Cloud

 

Salesforce Marketing Cloud also provides Personalization Strings, which are predefined variables that you can use. For example, if you want to retrieve the recipient's name, you can use the %%First Name%% variable as follows:

 


%%[ SET @NombreDestinatario = AttributeValue('First Name') ]%%



Variables Included in CloudPageURL

 

The variables you've passed through CloudPageURL can also be retrieved on your destination page. Suppose you've passed a variable "Color" in your URL, you can retrieve it like this:

 


%%[ SET @Color = RequestParameter('Color') ]%%

These three categories of variables allow you to personalize your destination pages according to recipient data, predefined variables, and parameters passed through links. Use these capabilities to create highly personalized experiences for your recipients.



CloudPageURL is a powerful tool in Salesforce Marketing Cloud that simplifies the creation of effective links and redirects. By understanding its structure and how to use it in combination with other functions, you can direct your subscribers to the right pages and provide them with personalized experiences.



In this video, you can see in detail how CloudPagesURL works and how to use it correctly to retrieve variables.

 

 


Download our ebook to support the online course here:

 

ebooks amscript for marketers

 


 

If you liked this article, share it!


Topic: SF Marketing Cloud