Shopify - Get Pages, Articles, Products & Collections by ID

Sitebee

Technical SEO
Staff member
If you are a Shopify web store owner, developer, Technical SEO or marketer. There will be times when you may need to retrieve a list of product ID's, Article ID's and Page ID's. Oddly enough Shopify only allows you this data via an API. Not everyone is familar with the Shopify API.

In this post I will show you how to retrieve those ID's without the need of going through the API. I have used a popular spiderering and scraping tool called Screaming Frog. Screaming Frog has a custom extraction tool built-in to allow you to scrape anything from the HTML within a webpages including the JS scripts.

The product ID's, Article ID's and Page ID's for Shopify are listed within scripts on each of the page template types. Look closely and will spot them if you know what to look for. Using the custom extraction tool I was able to Regex extract those IDs.

Below are the regular expressions to text match the Shopify product ID's, Article ID's and Page ID's.

shopify-page-id.PNG



Regex for Shopify Article ID (article.id)
Code:
 ("articles-.*?")

You can find the blog article ID embeded within the script shown in the Shopify analytic's image below.
articles.PNG



Regex for Shopify Page ID (page.id)
Code:
  ("pages-.*?")

You can find the page ID embeded within the script shown in the Shopify analytic's image below.
pages.PNG



Regex for Shopify Product ID (product.id)
Code:
 ("productId\":.*?")

The product ID is listed 3 times on the product pages. You only need to extract it once, if you do extract all 3 instances. Simply deleted the duplicate instances. You can find the product ID embedded within the script shown in the Shopify analytic's image below.
product-is-shopify.PNG


Need Help?
If you need help extracting the ID's data from the web store you are working on or with. Let me know, I might be able to help you out. I could crawl, extract and send the data to you.
 

Attachments

  • shopify-page-id.PNG
    shopify-page-id.PNG
    31.4 KB · Views: 19
  • shopify-page-id.PNG
    shopify-page-id.PNG
    31.4 KB · Views: 19
Last edited: