0

I have one email which has link to cloud page/ landing page. the URL is passing email address in url parameter and then ampscript is fetching all values from DE to the LP. But I am stuck with fetching content blocks in landing page.

her is what i have tried.

EMAIL:

    %%[
Var @landingPage, @key

set @key = Base64Encode(emailaddr)
set @landingPage = concat("https://pub.s7.exacttarget.com/n21?key=%%=v(@key)=%%")



]%%

Landing Page:

 %%[
var @key, @decode, @lastprod, @spend, @target

set @key = QueryParameter('key')
set @decode = Base64Decode(@key)
set @lastprod = FIELD(ROW(LookupRows("LoyaltyProgram", "EmailAddress", @decode),1),"AbandonedCartItem1")
set @spend =    FIELD(ROW(LookupRows("LoyaltyProgram", "EmailAddress", @decode),1), "TotalTransactionAmount")


IF @spend >= 200 THEN

 set @target = %%=ContentAreaByName('FY20\Jan20\content Blocks\test')=%%

 Else
  set @target = %%=ContentAreaByName('FY20\Jan20\content Blocks\loyal')=%%

  ENDIF




]%%

The page is erroring out as I am doing something wrong with if else condition or parameters fetching the content.

3 Answers 3

3

Thanks Gortonington, I got the solution now

%%[ 
SET @ContentID = "469963" 
SET @Content = ContentBlockbyID(@ContentID) 
]%% 

%%=TreatAsContent(@Content)=%%

this solution worked. First I called the content and then displayed it in LP.

1

EDIT

In email use:

%%[
Var @landingPage, @key

set @key = Base64Encode(emailaddr)
set @landingPage = concat("https://pub.s7.exacttarget.com/n21?key=", @key)
]%%


Click <a href="%%=RedirectTo(@link)=%%">here</a>

And on landing page use:

%%[
var @key, @decode, @lastprod, @spend, @target

set @key = QueryParameter('key')
set @decode = Base64Decode(@key)
set @lastprod = FIELD(ROW(LookupRows("LoyaltyProgram", "EmailAddress", @decode),1),"AbandonedCartItem1")
set @spend =    FIELD(ROW(LookupRows("LoyaltyProgram", "EmailAddress", @decode),1), "TotalTransactionAmount")
    IF @spend >= 200 THEN
    set @target = 'FY20\Jan20\content Blocks\test'
    Else
    set @target = 'FY20\Jan20\content Blocks\loyal'
    ENDIF
]%%

%%=ContentBlockByName(@target)=%%
1
  • thanks for reply and sorry for confusion if you didn't get my question. I want to retrieve HTML content block which i have created within content builder to a landing page based on rule which says If spend is more than 200 show this content on landing page. Commented Sep 26, 2019 at 12:32
0

The issue is that ContentAreaByName() is for Classic content only, not Content Builder. You will need to use ContentBlockByName() instead.

For example: %%=ContentBlockByName(@target)=%%

Secondly, you need to put the FULL path of your content, not just the subpath. This means that you need to include 'Content Builder\{{yourpath}}' for Content Builder and 'my content\{{yourpath}}' for Classic.

So likely target would need to be either SET @target = 'Content Builder\FY20\Jan20\content Blocks\loyal' or you would need to create a new var and concat this to your output.

e.g.

SET @target = 'FY20\Jan20\content Blocks\loyal'
SET @dir = 'Content Builder\'

%%=ContentBlockByName(Concat(@dir,@target))=%%
2
  • Hi Gortonington, I tried above code but it didn't worked and when i read the document it says "These functions support email messages only. For text-only parts of the email, such as From Address, From Name, or Subject Line, reference the code snippet block." I am not sure if there is any function to fetch content blocks in landing pages built under web studio. Commented Sep 27, 2019 at 15:11
  • I currently have used the BlockbyKey or BlockbyID functions inside Cloudpages successfully - I personally have not tried BlockByName, but I believe a coworker of mine has used it in CP before successfully. Commented Sep 27, 2019 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .