skip to Main Content

Is there any shopify admin api to get count of all customer which having tag xyz

3

Answers


  1. You can use a query to get all the customers with a specific tag.

    Example:
    /admin/customers/search.json?query=tag:wholesale

    From there you can count the items from the array.

    Login or Signup to reply.
  2. The only way to get customers total count by a specific tag using Shopify REST API is to fetch all of them using pagination and then actually count them.

    You can also do so without using the API (if it suits you) by filtering customers in the admin panel and then exporting the result using the “search” option in the export dialogue window, view example.

    Login or Signup to reply.
  3. Drip has suggested the right way. but if you have more than 250 results then you will defensively need to loop through the pages.

    with the updated Shopify Rest APIs they are facilitating the cursor based pagination and each response header you will get information about the nextPage if it exists.

    For more detail on this read

    i can not able to get page_info using shopify Api

    and in the coding you can do something like below, you can keep count or push data in empty array.

    $count = 0;
    do{
        $response = $shop->request('get','customers/search.json?query=tag:xyz?limit=250&page_info='.$nextPageToken);
        $count = $count + count($number_of_objects_in_response);
        $nextPageToken = $response['next']['page_token'] ?? null;
    }while($nextPageToken != null)
    

    for whole on cursor based pagination have a look here

    How to create pagination in shopify rest api using php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search