Ecommerce Shopify WordPress Discussion

How to create Shopify webhook for customer login?

I am trying to make my custom application to listen for webhooks from Shopify. I need to receive customer ID on customer login. Unfortunately Shopify don't have built in functionality. Is there any way I can achieve this? Thank you
There is no webhook for customer login natively available. we can manually trigger web-hook by our custom logic. Put this JS in your theme.liquid file <script> let loginWebhook = false; {% if customer != nil %} if(!window.localStorage.getItem('logged')) { loginWebhook = true; } {% else %} window.localStorage.removeItem('logged') {% endif %} </script> Put this JS in your main-account.liquid file <script> if(loginWebhook) { window.localStorage.setItem('logged', 1); console.log('CALL endpoint of webhook', '{{- customer.email -}}'); // Make a fetch request here and call the webhook endpoint // Manually call webhook /* const webhookURL = 'http://webhookurl.com/log-login'; const webhookData = { 'email': '{{- customer.email -}}', // HERE add other data which is needed in webhook // customer id etc.. }; fetch(webhookURL, { method: "POST", // *GET, POST, PUT, DELETE, etc. headers: { "Content-Type": "application/json", }, body: JSON.stringify(webhookData), }); */ } </script> Logic when the customer object is available on the page, we check if we have already called the webhook or not. if we did not call webhook we set loginWebhook to true now the customer will land on the account page` after login every time here we check loginWebhook if it's true we call webhook we set the localStorage value logged to 1 so next time we don't call the webhook Now user will surf the site, and all that time we will not call the webhook as we already called it and store info into localStorage. If the customer will logout then we remove the logged value from localStorage. So, Now next time when a user logs in we will again call webhook and we repeat from the top. Implementation in live-action [Shopify Customer Login Webhook] if any doubt please comment.

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.