When making a sales report from your Shopify sales data, you may realize that Shopify does not allow you to export the customer creation date, which is useful in analyzing the sales trends. The data exists, but you have to stare at a hard-to-read format by accessing this page, where you replace the word “mystore” with the name of your store.
If you already have hundreds of customers and orders, you'll probably need a way to pull the creation data data alongside your table. So, what are some of the workarounds here?
Different services over the internet include application programming interfaces, or APIs, which allow communication between the platform and other software. Developers use APIs so that their own systems can communicate with the platform in a faster and easier way. The data that can be accessed through APIs are structured but not formatted for the use of the end user. The developers would have to develop their own code to process and format it. For example, several developers of apps that use Facebook take advantage of the Facebook API in order to use that platform. You can learn more from this HowtoGeek article.
APIs also allow access to data that the platform has. Shopify has their own API that can be accessed via browser, and the documentation is available here. APIs require authentication to prevent access to full data by non-authenticated end users.
The customer data stored at Shopify include the names, addresses, currencies used, and contact information. It also includes the date when the customer record was created. The data is stored in JSON format, which makes it structured but is tricky to read for the end user. To access the data, first log in to your Shopify store account, and ensure that you have admin access to it. Then, copy the following URL, replace <name_of_your_store></name_of_your_store> with the link to your store, and paste it to the address bar of your browser:
https://<name_of_your_store></name_of_your_store>.myshopify.com/admin/api/2020-07/customers.json?fields=id,last_name,first_name,created_at
The code above will give you a structured file containing the name of the customers and the date their record was created. The Shopify documentation contains more information on the fields included in their data record.undefined
We can use Javascript to process and display the data we get from the previous step. We modify the sample code from W3Schools for our data (which contains Customer ID, First name, Last name, and Date created). Use the following code:
<!DOCTYPE html>
<html></html>
<body></body>
<p>Customer Names and Date Created</p>
<table border="1" id="demo"></table>
<script></script>
var myObj, i, j, x = "";
myObj = *insert_data_here*;
x += "<tr><th> Customer Name </th><th> Customer Creation Date </th><th> Customer ID</th></tr>"
for (i in myObj.customers) {
x += "<tr><td>" + myObj.customers[i].last_name + " " + myObj.customers[i].first_name + "</td><td>" + myObj.customers[i].created_at + "</td><td>" + myObj.customers[i].id + "</td></tr>";
}
document.getElementById("demo").innerHTML = x;
Copy the code above and paste them in Notepad. Afterwards, copy the data you got from Shopify API and paste them in the part where *insert_data_here* is written. Then, save the file as customer.html in a chosen location in your computer. Finally, you can open it in your browser. A sample output is shown below:
The advantage of this method is having no third-party intermediary, but significant disadvantages are the several steps needed and that you may be prone to errors if not done correctly.
If figuring out the code and pulling data is too difficult, you could try out Lido instead! We'd be remiss not to mention how Lido can automatically help you track customer creation dates and see the sales trends you need to make decisions for your business.