Ecommerce Shopify WordPress Discussion

Retrieving total count of customers on Shopify [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 days ago. Improve this question I have struggled on making a widget for my Shopify store that shows total accounts created and by country. Anyone could help me to do it? I have tried a lot of tutorials but they didn't help. <div id="customer-widget"></div> <script> document.addEventListener('DOMContentLoaded', function() { fetch('/admin/api/2023-01/customers/count.json') .then(response => response.json()) .then(data => { document.getElementById('customer-widget').innerHTML = 'Customers: ' + data.count; }) .catch(error => console.error('Error fetching customer count:', error)); }); </script>
You cannot get a count of customers from Admin API without being in an App that is secure and therefore as authorization tokens to get that kind of information. Your example code calls the Admin API with no authentication. So obviously, that will never work. If you wanted to add a customer count to your store you can do it many ways. in the admin, using admin UI extensions, you could query customer count and display it somewhere in your admin for yourself. glamour! in the store itself, facing customer, make an App Proxy call to your backend and get the customer count from the proxy call in your front-end, render a Shop metafield somewhere useful on your store, where you update that metafield with a value when you add customers. Beyond those basics, you are free to invent other patterns, as long as you understand the concept of Admin API being secure.

February 4, 2024

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.