0

We use AMPscript to add our discount codes to our email URLs. We add something like this to the top of our emails:

%%[
Var @campaign, @pcode
Set @campaignID = "campaigncode"
Set @pcode = "123456789"
]%%

and the URLs within the email look like this:

www.website.com/website?utm_campaign=%%= v(@campaignID) =%%&pcode=%%= v(@pcode) =%%

We want to try using Einstein Content Selection for our secondary images but I am having trouble getting the campaignID and pcode dynamically added. In the Einstein Content Selection asset library, I added the URL like I do for the other links in the email:www.website.com/website?utm_campaign=%%= v(@campaignID) =%%&pcode=%%= v(@pcode) =%%

But when I insert the Einstein Content Selection content block and send the email, it doesn't add in the parameters from the top of the email and so the discount isn't added to the link. How can I do this?

Here is what the HTML is of the Einstein Content Selection block is:

%%[
/*
  Einstein Content Selection -- Modify At Your Own Risk
*/

VAR @subscriber_id, @subscriber_key, @mid, @mid_dash, @hash_subid, @hash_subkey, @hash_email
SET @subscriber_id = SubscriberID
SET @subscriber_key = lowercase(_subscriberkey)
SET @email = emailname_
SET @mid = memberid
SET @mid_dash = Concat(@mid, "-")
SET @hash_subid = SHA256(Concat(@mid_dash,@subscriber_id))
SET @hash_subkey = SHA256(Concat(@mid_dash,@subscriber_key))
SET @hash_email = SHA256(Concat(@mid_dash,@email))
IF EMPTY(@seed) THEN
  VAR @seed
  SET @seed = Format(now(), "ddHHmmss")
ENDIF
]%%

<a href="https://ecs.us.sfmc-einstein.com/einstein/api/block/4aca42bb-e21f-47b1-8e08-38dac3fbe901/selection?subscriber_id=%%=v(@hash_subid)=%%&subscriber_key=%%=v(@hash_subkey)=%%&context=%%_messagecontext%%&email=%%=v(@hash_email)=%%&job_id=%%jobid%%&send_date=%%xtyear%%-%%xtmonthnumeric%%-%%xtday%%&seed=%%=v(@seed)=%%" alias="ECSlink_alias"><img src="https://ecs.us.sfmc-einstein.com/einstein/api/block/4aca42bb-e21f-47b1-8e08-38dac3fbe901/selection?subscriber_id=%%=v(@hash_subid)=%%&subscriber_key=%%=v(@hash_subkey)=%%&context=%%_messagecontext%%&email=%%=v(@hash_email)=%%&job_id=%%jobid%%&send_date=%%xtyear%%-%%xtmonthnumeric%%-%%xtday%%&seed=%%=v(@seed)=%%&image=true" width="auto" height="auto" style="max-width: 100%"></a>
%%[
/*
  Einstein Content Selection -- End
*/
]%%
2
  • Please update your question to include a sample of the AMPscript you're using for the Einstein links. Commented Jun 21, 2021 at 16:26
  • Updated my answer below based on the Einstein sample you provided. Commented Jun 22, 2021 at 12:12

2 Answers 2

1

I'd suggest parameterizing your append variables:

In the init block:

%%[

set @campaignID = "campaigncode"
set @pcode = "123456789"

set @params1 = ""
set @params1 = concat(@params1, "utm_campaign=", @campaignID)
set @params1 = concat(@params1, "&pcode=", @pcode)

]%%

In the body:

<a href="%%=redirectto(concat("https://www.website.com/website?", @params1)=%%">link</a>

I'd give the Einstein Content links the same treatment:

%%[

VAR @subscriber_id, @subscriber_key, @mid, @mid_dash, @hash_subid, @hash_subkey, @hash_email
SET @subscriber_id = SubscriberID
SET @subscriber_key = lowercase(_subscriberkey)
SET @email = emailname_
SET @mid = memberid
SET @mid_dash = Concat(@mid, "-")
SET @hash_subid = SHA256(Concat(@mid_dash,@subscriber_id))
SET @hash_subkey = SHA256(Concat(@mid_dash,@subscriber_key))
SET @hash_email = SHA256(Concat(@mid_dash,@email))

IF EMPTY(@seed) THEN
  VAR @seed
  SET @seed = Format(now(), "ddHHmmss")
ENDIF

set @params2 = ""
set @params2 = concat(@params2, @params1)
set @params2 = concat(@params2, "&subscriber_id=", @hash_subid)
set @params2 = concat(@params2, "&subscriber_key=", @hash_subkey)
set @params2 = concat(@params2, "&context=", _messagecontext)
set @params2 = concat(@params2, "&email=", @hash_email)
set @params2 = concat(@params2, "&job_id=" ,jobid)
set @params2 = concat(@params2, "&send_date=", xtyear, "-" , xtmonthnumeric, "-" , xtday)
set @params2 = concat(@params2, "&seed=", @seed)

set @params3 = ""
set @params3 = concat(@params3, @params2)
set @params3 = concat(@params2, "&image=true")

]%%

<a href="https://ecs.us.sfmc-einstein.com/einstein/api/block/4aca42bb-e21f-47b1-8e08-38dac3fbe901/selection?%%=v(@params2)=%%" alias="ECSlink_alias"><img src="https://ecs.us.sfmc-einstein.com/einstein/api/block/4aca42bb-e21f-47b1-8e08-38dac3fbe901/selection?%%=v(@params3)=%%" width="auto" height="auto" style="max-width: 100%">
</a>


3
  • Hey @AdamSpriggs, I'm still having trouble getting the campaign id & pcode to apply. Here is the link I'm using as the destination URL for my assets in the Einstein Content Selection: website.com?utm_source=newsletter&utm_medium=email&utm_…. ( I had put the link as www.website.com?utm_source=newsletter&utm_medium=email&utm_campaign=%%= v(@campaignID) =%%&pcode=%%= v(@pcode) =%% but the system seems to add extra characters) Commented Jul 13, 2021 at 20:26
  • I am not able to set up the link as you mentioned (<a href="%%=redirectto(concat("website.com/website?", @params1)=%%">link</a>) in the Einstein Content Selection Asset Library,; it says it is invalid Commented Jul 13, 2021 at 20:26
  • also, i tried making the HTML of the Einstein Content Selecton block in my email like you said, but whenever i copy in your suggestions, whenever I leave the editing of the email, the edits disappear and the block goes back to what it originally had Commented Jul 13, 2021 at 20:26
0

Nice work Adam!

Another option is to use Parameter Management within the Marketing Cloud if they are parameters that are used consistently.

As an exercise, I added a parameter called blurb and populated an AMPscript variable @blurb in the email and the parameter was passed through correctly with my Parameter Management Tracking String setup as:

utm_source=sfmc​&utm_medium=email​&utm_campaign=%%emailname_%%​&utm_term=%%linkname%%​&utm_id=%%jobid%%​&sfmc_id=%%subscriberid%%​&blurb=%%=v(@blurb)=%%

Note: I only added &blurb=%%=v(@blurb)=%% to the default.

Help doc: https://help.salesforce.com/articleView?id=sf.mc_overview_parameter_management.htm&type=5

0

You must log in to answer this question.

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