{"id":22757,"date":"2023-11-02T15:32:14","date_gmt":"2023-11-02T14:32:14","guid":{"rendered":"https:\/\/www.marketinet.com\/blog\/ampscript-cloudpagesurl-retrieve-variables\/"},"modified":"2025-04-08T11:39:57","modified_gmt":"2025-04-08T09:39:57","slug":"ampscript-cloudpagesurl-retrieve-variables","status":"publish","type":"post","link":"https:\/\/www.marketinet.com\/en\/blog\/ampscript-cloudpagesurl-retrieve-variables\/","title":{"rendered":"AmpScript: Proper Use of CloudPagesURL and How to Retrieve Variables"},"content":{"rendered":"<p>In Salesforce Marketing Cloud, CloudPageURL is an essential function that allows you to set your CloudPages as destinations.<\/p>\n<p>\u00a0<\/p>\n<p><span class=\"EOP SCXW173562801 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:150,&quot;335559739&quot;:150,&quot;335559740&quot;:240}\"><!--more--><\/span><\/p>\n<p>\u00a0<\/p>\n<p>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.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Structure of the CloudPageURL Function<\/strong><\/p>\n<p>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.<\/p>\n<p>It also has optional fields for passing multiple pairs of variables and values.<\/p>\n<p>\u00a0<\/p>\n<p>Here is the basic structure of the function:<\/p>\n<p>\u00a0<\/p>\n<p>&lt;ahref=&#8221;%%=CloudPagesURL(1234,&#8217;variable1&#8242;,&#8217;valor1&#8242;,&#8217;variable2&#8242;,&#8217;valor2&#8242;,&#8230;)=%%&#8221;&gt;Visitar a&gt;<\/p>\n<p>This code will generate a link to your CloudPage with the ID 1234.<\/p>\n<p>You can add as many variable-value pairs as you like, making it easy to customize your links.<\/p>\n<h2>Using RedirectTo and Concat<\/h2>\n<p>\u00a0<\/p>\n<p>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&#8217;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:<\/p>\n<p>\u00a0<\/p>\n<p>&lt;a href=&#8221;%%=RedirectTo(CONCAT(CloudPagesURL(1234),&#8217;?tema=marketing&#8217;))=%%&#8221;&gt;Visitar P\u00e1gina&lt;\/a&gt;<\/p>\n<p>\u00a0<\/p>\n<p>This way, you ensure that the generated links work correctly even in emails.<\/p>\n<h2>Passing Parameters<\/h2>\n<p>\u00a0<\/p>\n<p>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:<\/p>\n<p>\u00a0<\/p>\n<p>&lt;a href=&#8221;%%=RedirectTo(CONCAT(CloudPagesURL(1234,&#8217;color&#8217;,&#8217;rojo&#8217;)))=%%&#8221;&gt;Visitar P\u00e1gina&lt;\/a&gt;<\/p>\n<p>\u00a0<\/p>\n<p>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.<\/p>\n<p>\u00a0<\/p>\n<h2>How to Retrieve Variables on the Destination Page<\/h2>\n<p>\u00a0<\/p>\n<p>When using CloudPageURL, you can pass three types of variables to your destination page:<\/p>\n<p>\u00a0<\/p>\n<h4>Sendable Data Extension Variables<\/h4>\n<p>If you&#8217;ve included specific variables in your sendable Data Extension, you can retrieve them on your destination page using AMPscript. Let&#8217;s say you have a variable called &#8220;NombreProducto&#8221; in your Data Extension; you can retrieve it as follows:<\/p>\n<p>\u00a0<\/p>\n<p>%%[ SET @NombreProducto = AttributeValue(&#8216;NombreProducto&#8217;) ]%%<\/p>\n<p>\u00a0<\/p>\n<h4>Personalization String Variables in Marketing Cloud<\/h4>\n<p>\u00a0<\/p>\n<p>Salesforce Marketing Cloud also provides Personalization Strings, which are predefined variables that you can use. For example, if you want to retrieve the recipient&#8217;s name, you can use the %%First Name%% variable as follows:<\/p>\n<p>\u00a0<\/p>\n<p>%%[ SET @NombreDestinatario = AttributeValue(&#8216;First Name&#8217;) ]%%<\/p>\n<h4>Variables Included in CloudPageURL<\/h4>\n<p>\u00a0<\/p>\n<p>The variables you&#8217;ve passed through CloudPageURL can also be retrieved on your destination page. Suppose you&#8217;ve passed a variable &#8220;Color&#8221; in your URL, you can retrieve it like this:<\/p>\n<h3>\u00a0<\/h3>\n<p>%%[ SET @Color = RequestParameter(&#8216;Color&#8217;) ]%%<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>In this video, you can see in detail how CloudPagesURL works and how to use it correctly to retrieve variables.<\/p>\n<p>\u00a0<\/p>\n<div class=\"hs-responsive-embed-wrapper hs-responsive-embed\">\n<div class=\"hs-responsive-embed-inner-wrapper\"><iframe class=\"hs-responsive-embed-iframe lazyload\" data-src=\"\/\/www.youtube.com\/embed\/Xkj06tk-dEo\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" data-service=\"youtube\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe><\/div>\n<\/div>\n<p>\u00a0<\/p>\n<p><br \/>Download our ebook to support the online course here:<\/p>\n<p>\u00a0<\/p>\n<p>{{cta(&#8216;a27dec50-3331-4b83-9269-4becaff9a922&#8217;)}}<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.marketinet.com\/ebooks\/ampscript-for-marketers?utm_source=blog&amp;utm_medium=inbound&amp;utm_campaign=cta_recurso_blog_ebook_ampscript_for_marketers\"><img decoding=\"async\" width=\"592\" height=\"148\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2023\/11\/cap2.png\" alt=\"\" class=\"wp-image-27031 lazyload\" data-srcset=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2023\/11\/cap2.png 592w, https:\/\/www.marketinet.com\/wp-content\/uploads\/2023\/11\/cap2-480x120.png 480w\" data-sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 592px, 100vw\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 592px; --smush-placeholder-aspect-ratio: 592\/148;\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In Salesforce Marketing Cloud, CloudPageURL is an essential function that allows you to set your CloudPages as destinations. \u00a0<\/p>\n","protected":false},"author":36,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[165],"class_list":["post-22757","post","type-post","status-publish","format-standard","hentry","category-sin-categorizar","tag-sf-marketing-cloud"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts\/22757","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/comments?post=22757"}],"version-history":[{"count":0,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts\/22757\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/media?parent=22757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/categories?post=22757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/tags?post=22757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}