0

I'm having an issue whereby i have a 'thank you' cloudpage which customer lands on after submitting a form in email. The cloudpage then sends a triggered send email.

The problem is that customers are receiving duplicate emails and according to MC support this is because the cloudpage is re-loading in micro secondswhich re-trigggers the email. I want to stop this from happening here is my AMPscript on the cloudpage

%%[

SET @emailid = AttributeValue("emailaddr") 
SET @subKey = AttributeValue("_subscriberkey") 
VAR @ts, @tsDef, @ts_extkey, @ts_email, @ts_sub, @ts_statusCode, @ts_statusMsg, @errorCode
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_extkey = "Offeremail"
SET @ts_email =  @emailid 

SetObjectProperty(@tsDef, "CustomerKey", @ts_extkey)
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
 
SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "EmailAddress", @ts_email)
SetObjectProperty(@ts_sub, "SubscriberKey", @subKey)
AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)

IF @ts_statusCode != "OK" THEN
  RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
ENDIF

]%%
3
  • Is redirecting completed triggers to another page an option? I think the easiest solve is to have a redirect to a TY page after the trigger runs will solve this without having to rework or debug your code. Feb 22 at 21:59
  • When you say redirect to another page do you mean redirect to another cloud page? If you mean a different web landing page altogether, the problem is I’m not sure how I would then be able to keep the triggered send that is sent when customer lands on the TY page
    – CRMdelaCRM
    Feb 23 at 5:46
  • Please share the complete code [by removing any business/sensitive details], so this helps the community to guide properly... The issue seems to be that the cloud page with Trigger code is being loaded multiple times. Feb 26 at 5:21

2 Answers 2

1

As one of the comments says (just what I understood), you could have an "auxiliar/intermediate" empty cloudpage, whose only function is to execute the trigger and then redirect to the "Thank you page", where you won't have any code to execute. (Be aware that linking an email to an empty cloudpage with a redirect in it could be suspicious for some email clients)

Another option that doesn't involve new cloudpages, would be to have a log data extension where you check before sending the trigger from the "Thank you" page, wrapping your code with a conditional based on a "Lookup" function result. But I'm not sure if this will work if the reload of the cloudpage is that fast.

It's my first contribution so I hope I have explained properly.

0

Inserted what I had in mind below. Simply adding a redirect to a thank you page when the code renders successfully will move visitors out of the page with the processing code. The redirect can be to a CloudPage or a non-SFMC page - the goal is get a visitor out of the page with the processing code. Either of the two will accomplish this.

...
IF @ts_statusCode != "OK" THEN
RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
ELSE
Redirect("https://yourDomain.com/thankYouPage")
ENDIF
...

There are other things to consider too - like making sure the page doesn't reprocess if they use the back button (in that case, you can use a LookUp or some statement to verify if they qualify). Additionally, in the Redirect() function, you could also use the CloudPagesURL() function. This would allow you to do a look up on SubscriberKey or even pass parameters securely that could be leveraged on the thank you page - for example, their first name or a summary of what was accomplished by the processing.

*I would also recommend that your RaiseError() code is preceded by something like an InsertData() or UpsertData() function to capture the errors in a centralized location.

You must log in to answer this question.

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