1

We have a marketing cloud email link with <a href="mailto:">

When the link is clicked along with allowing the customer to email us, we also want to pass parameters to a cloud page (they should not see the cloud page part so it should happen in the background)

Essentially, we want to record the click into a DE which will be used for suppression.

Below is my code in the email and cloud page which isn't working. I feel i am not approaching this the right way. Can this be done differently?

Email html content block

%%[
Set @cno = AttributeValue("customer") 
Set @appnum = AttributeValue("applicationNumber") 
Set @cloudPageURL = RedirectTo(CloudPagesURL(92, 'cno', @cno, 'appnum', @appnum))
]%%

%%[
set @scriptBeg = Concat('<','script','>')
set @scriptEnd = Concat('<','/','script','>')
]%%


<a href=“mailto:[email protected]?subject=some subject" onclick="redirectToCloudPage()">
<span>I am interested</span>
</a>

%%=v(@scriptBeg)=%%

function redirectToCloudPage() {
  window.location.href = "%%=v(@cloudPageURL)=%%";
}

%%=v(@scriptEnd)=%%

My code in the cloud page (92)

%%[ 
set @cno = Requestparameter('cno') 
set @appnum = Requestparameter('appnum') 
set @response = "I am interested"

UpsertDE("Responses",1,"ApplicationNumber",@appnum,"Customer",@cno,"Response",@response)
]%%

1 Answer 1

5

This probably doesn’t work because of your email client, and in fact, it shouldn’t. Using JavaScript directly inside an email is generally not recommended and is often not supported by most email clients. This is because embedding js in emails can pose a security risk, as it can potentially execute malicious code on the recipient's device. To protect users from such threats, email clients typically disable js execution and may even block or filter emails containing js.

To achieve what I assume you’re trying to do, I’d create a button in the email that says “I’m interested” and I would direct it to a CloudPage. On the CloudPage you could save a record to a DE and use a triggered send to send an email to [email protected] with either generic content and subject, or if you embedded a form on the CloudPage, the email could contain info from the form.

Alternately, you can use the solution for tracking mailto links described by Gortonington here: Can we track "tel:" and "mailto:" clicks from Email

You must log in to answer this question.

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