How to generate the token to send a customer activation account email outside of Shopify?

linia
Excursionist
15 1 15

Hi there,

 

I'm creating a membership site for digital products and need to send customer activation emails either through automation within Shopify or through automation outside of Shopify.


I'm trying not to use products that have monthly fees, and doing this programmatically.  So far, it seems Shopify's automation tools do not have a function to send an 'activate account' email to a specific customer (say, once they've had a tag added).


Additionally, there are no actions to send that email with Zapier.

I've decided to try to generate the email myself... the link comes in this format:
https://[site domain]/account/activate/[customer ID]/[token]

I can get everything to build this link, except for that final token. I am not sure how to generate the token for the URL... is there a specific format to it or an API call I can make to generate it?

Any help would be appreciated.  I'm tech savvy and do have coding experience, but am extremely new to Shopify, so please provide as much context as possible if you can help.

Thank you so much! I've learned a lot from these forums already...

Replies 2 (2)

sherpabot
Shopify Partner
16 0 2

I am having the same issue. The liquid references do not even show that the activate URL attribute exists. I tried to use the JSON filter but it's not allowed in the email template 🥲. I get the token when the link is clicked from the URL but that is POST hoc. 

I hope a shopify member can clarify this somewhere

sherpabot
Shopify Partner
16 0 2

I just came up with a solution for my needs, that may be helpful to you. 

1. Inside the email template for activating customers you need to redirect the customer to your app/site and make sure you are using the 

?activation_url=

param. See this link for more info (https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/customer-accounts#step-...). I have an email template example listed below. I am sending the user to the localhost domain and afterward appending the activation URL generated from Shopify.
Screenshot 2024-01-11 at 3.25.33 PM.png

2. Once the customer clicks on the activation URL renders down to the link provided in the example "https://example.myshopify.com/account/activate/<customer_id>/<activation_token>" . You need to create client-side logic to "clean" the URL by decoding it so that you get the same format from above. Once he link is decoded you can run simple string manipulation to extract the customer ID and activation token. 
Screenshot 2024-01-11 at 3.22.24 PM.png

3. Use the two figures to make your activation request with the "customerActivate" endpoint from Shopify. 

I am using Nextjs 14 and this worked for me. You should be able to perform something similar easily. 

I hope that helps. Similarly, I hope that the Shopify team clarifies that process within their docs. Good luck!