简体   繁体   English

带有产品图片,URL和名称的Ampscript查找产品推荐表

[英]Ampscript Lookup Product Recommendation Table with Product Images, URLs and Names

I have this table (Product_Recommendations) of recommended products (4) per email address. 每个电子邮件地址都有推荐产品(4)的此表(Product_Recommendations)。

 <style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;} .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;} .tg .tg-0lax{text-align:left;vertical-align:top} </style> 
 <table class="tg"> <tr> <th class="tg-0lax">EmailAddress</th> <th class="tg-0lax">Product_Name_1</th> <th class="tg-0lax">Product_Image_1</th> <th class="tg-0lax">Product_URL_1</th> <th class="tg-0lax">Product_Name_2</th> <th class="tg-0lax">Product_Image_2</th> <th class="tg-0lax">Product_URL_2</th> <th class="tg-0lax">Product_Name_3</th> <th class="tg-0lax">Product_Image_3</th> <th class="tg-0lax">Product_URL_3</th> <th class="tg-0lax">Product_Name_4</th> <th class="tg-0lax">Product_Image_4</th> <th class="tg-0lax">Product_URL_4</th> </tr> <tr> <td class="tg-0lax">test1@gmail.com</td> <td class="tg-0lax">Banana Chips</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/81U4W10VayL._SY679_.jpg</td> <td class="tg-0lax">https://www.amazon.com/dp/B079VYSKDL/</td> <td class="tg-0lax">Rice Krispie Squares</td> <td class="tg-0lax">http://images.kglobalservices.com/www.ricekrispies.ca_en/en_ca/recipe/kicrecipe-23578/kicfileasset-122362__0048_original_vanilla.jpg</td> <td class="tg-0lax">http://www.ricekrispies.ca/en_CA/recipes/original-rice-krispie-squares-with-vanilla-rice-krispies-recipe.html</td> <td class="tg-0lax">Peanut Butter</td> <td class="tg-0lax">https://ll-us-i5.wal.co/asr/c8947428-64a5-4fc8-b8a6-f39e99f4e8ff_1.be53020d2e3a614597a2e922384cbe0b.jpeg-65dd04924f94d1da234876f07ed26ed101838351-optim-450x450.jpg?odnBg=FFFFFF</td> <td class="tg-0lax">https://www.amazon.com/Skippy-Creamy-Peanut-Butter-Ounce/dp/B0005ZH4QI</td> <td class="tg-0lax">Gatorade</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/71tpcOn5JoL._SY679_.jpg</td> <td class="tg-0lax">https://www.amazon.com/Gatorade-Thirst-Quencher-Glacier-Freeze/dp/B000R32OOU/ref=pd_sim_325_5?_encoding=UTF8&amp;pd_rd_i=B000R32OOU&amp;pd_rd_r=559a5bc6-c1b9-11e8-a3f5-a953cb310f5f&amp;pd_rd_w=fWcKC&amp;pd_rd_wg=yJcCm&amp;pf_rd_i=desktop-dp-sims&amp;pf_rd_m=ATVPDKIKX0DER&amp;pf_rd_p=18bb0b78-4200-49b9-ac91-f141d61a1780&amp;pf_rd_r=2Z91KVV5TEG2Q2ZQ4570&amp;pf_rd_s=desktop-dp-sims&amp;pf_rd_t=40701&amp;psc=1&amp;refRID=2Z91KVV5TEG2Q2ZQ4570</td> </tr> <tr> <td class="tg-0lax">test2@gmail.com</td> <td class="tg-0lax">Applesauce</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/811TRgBN2gL._SX522_.jpg</td> <td class="tg-0lax">https://www.amazon.com/dp/B073JGKQB9?</td> <td class="tg-0lax">Pepsi</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/81I8cacfOUL._SX522_.jpg</td> <td class="tg-0lax">https://www.amazon.com/dp/B00NU5ZZJI/ref=sspa_dk_detail_5?psc=1&amp;fpw=pantry</td> <td class="tg-0lax">Cashews</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/51b00pIFJnL.jpg</td> <td class="tg-0lax">https://www.amazon.com/dp/B01H5GB8ZW/ref=sspa_dk_detail_5?psc=1&amp;fpw=pantry</td> <td class="tg-0lax">Cheerios</td> <td class="tg-0lax">https://images-na.ssl-images-amazon.com/images/I/91DlHO9Y69L._SY679_.jpg</td> <td class="tg-0lax">https://www.amazon.com/Cheerios-Naturally-Flavored-Sweetened-Cereal/dp/B07D3FFTH2/</td> </tr> </table> 

I want to add these products into my email, using ampscript lookup. 我想使用ampscript查找将这些产品添加到我的电子邮件中。 I tried the following, but it was erroring out in Marketing Cloud: 我尝试了以下操作,但是在Marketing Cloud中出错了:

%%[ 
VAR @emailAddr, @p1_name, @p1_url, @p1_image
set @emailAddr = EmailAddress("emailaddr")
SET @p1_name = (Lookup("Product_Recommendation", "Product_Name_1" EmailAddress",@emailaddr))
SET @p1_url = (Lookup("Product_Recommendation", "Product_URL_1" EmailAddress",@emailaddr))
SET @p1_image = (Lookup("Product_Recommendation", "Product_Image_1" EmailAddress",@emailaddr)) 
]%%

Not sure what I am doing wrong. 不知道我在做什么错。 Thanks! 谢谢!

Should be something like this: 应该是这样的:

%%[ 

VAR @emailAddr, @p1_name, @p1_url, @p1_image
set @emailAddr = AttributeValue("emailaddr")

SET @p1_name = Lookup("Product_Recommendation", "Product_Name_1", "EmailAddress", @emailaddr)
SET @p1_url = Lookup("Product_Recommendation", "Product_URL_1", "EmailAddress", @emailaddr)
SET @p1_image = Lookup("Product_Recommendation", "Product_Image_1", "EmailAddress", @emailaddr)

]%%

You were missing a comma and a double-quote on in your lookup functions. 您在查找功能中缺少逗号和双引号。

If you're looking for some more AMPscript lookup examples, I have a bunch here on my blog 如果您正在寻找更多AMPscript查找示例,那么我的博客上有很多内容

Reference : 参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM