Skip to main content

Hi.  My eCommerce website needs to run JavaScript code so a 3rd party can send the customer a gift. The JavaScript code worked on the Thank You page, but I need to have a few-day delay before the script runs, so I'm trying to do this with Zapier instead. But Zapier is giving the following error when the same code is used there:

The run javascript could not be sent to Code by Zapier. SyntaxError: Unexpected token <

Zapier Support could not help, and I couldn't find the solution in Zapier's documentation.

Can someone please help modify the short code below, so that it can be run by Zapier?

<script src="https://members.thirdparty.com/jsapi/fbDE_Voucher.min.js"></script>
<script>
window.onload = function(){
var fdDE_detail = {
"fbDE_sender":'12345-67890',
"fbDE_fullname":"'"+inputData.CustName+"'",
"fbDE_email":"'"+inputData.CustEmail+"'",
"fbDE_amount":inputData.VoucherValue,
"fbDE_business":54321,
"fbDE_message":'Thank you for your purchase!'
}
fbDEVoucher(fdDE_detail);
}
</script>

The variables CustName, CustEmail, and VoucherValue are from prior Zapier steps. The first 2 need to be within single quotes, and the third is an integer (not requiring quotes). Please see image below:

 

Does anyone know how to fix the above error (in bold) so this code runs?

Appreciate your help! Thanks.

Hi @SamK ,

Thanks for reaching out!

Tagging in @ikbelkirasan to see if they can assist here. @ikbelkirasan any ideas? 


Hi @Liz_Roberts ,

Thanks for the follow-up.

We can close this, as I came across a somewhat-hidden Zapier integration which solves the problem.

Thanks,

Sam


@SamK Are you able to share which integration you used in case someone else is looking to do the same thing? Thanks!


Hello Sam,

It looks like Nikki from our Support team responded back to you:

Based on my testing of Zapier so far, it doesn't seem like Zapier would have the updated Shopify data for the customer. It seems like in 7 days it would still be using the initial data, which excludes new tags (which identify next steps taken by the customer). If that's the case (please confirm), kindly let me know: How can Zapier make use of the updated data for that specific customer?

You have the right idea here. Zapier WOULD run on the data initially found from say, the "New Customer" or "New Order" trigger if you used a Delay by Zapier step.

However, following a 7 day delay, you could go on to use a "Find Customer" step, which would look up the current state of the customer, including what tags they have currently. So, it is indeed possible to get that updated data, using a "Find" step.

Can you please help modify the short code above so that it can be run by Zapier?

Our Code app is an advanced feature, and I’m afraid we aren’t able to help you create or debug your code through our support channel. I’m very sorry about that!

We do have some resources in our help section:
https://zapier.com/help/code/#introduction
https://zapier.com/help/how-get-started-code-zapier/
https://zapier.com/help/code-examples/

The best place to ask for help with your code is stackoverflow.com. Just tag your question with a “Zapier” tag and usually there will be folks who’d be willing to help you out. You can see all the questions that have already been asked here: stackoverflow.com/questions/tagged/zapier

I hope this helps answer your questions, but please let me know If there's anything that's unclear or you've got something else you'd like to run by me. I'm here to help!

Warmly,

Nikki