I have ampscript to be used for mobile connect triggered in Journey Builder The SMS does not send but when I replace with just plain text, it does.

Is there any errors with my code?

Test SMS via Journey. 

var @spc
set @len = length(AttributeValue('_SubscriberKey')
set @key = AttributeValue('_SubscriberKey')

if  @len == 4 then
set @spc = concat('########',@key)

elseif @len == 8 then
set @spc = concat('####',@key)

elseif @len == 10 then
set @spc = concat('##',@key)

set @spc = AttributeValue('_SubscriberKey')

set @enc = Base64Encode(@spc)


Encrypted URL: http://cloud.e.mycomp.com/SGTestProfilePage?pk=%%=v(@enc)=%%
Plain Text: http://cloud.e.mycomp.com/SGTestProfilePage?sk=%%_SubscriberKey%%

1 Answer 1


You'll need to provide some more information when you say the SMS does not send. Is it displaying an error? Is it sending a blank SMS text? Are you able to send a static SMS text?

Also it looks like you're using Base64Encode to encrypt values. Base64Encode is not very secure, I would use the CloudPagesURL function to pass data to your Cloud Page. You can access _SubscriberKey or emailaddr as first class strings and do not need to worry about Base 64 encoding which can be hacked.

%%=CloudPagesURL(ID, 'spc', @spc)=%%

CloudPageURL documentation: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/cloudpagesurl.htm

You must log in to answer this question.

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