# Scrape product data from any e-commerce site with a dataLayer (`eloquent_mountain/scrape-product-data-from-any-e-commerce-site`) Actor

Scrapes e-commerce product data from any (e-commerce) website that has a dataLayer object (mostly used in google analytics implementations). It returns all product data in multiple data formats. Also available as an API to integrate with your own or other products. Circumvents the Cookie wall.

- **URL**: https://apify.com/eloquent_mountain/scrape-product-data-from-any-e-commerce-site.md
- **Developed by:** [Paco](https://apify.com/eloquent_mountain) (community)
- **Categories:** E-commerce
- **Stats:** 461 total users, 3 monthly users, 100.0% runs succeeded, 6 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Scrape product data from any e-commerce site with a dataLayer

This Product Data Scraper is a powerful tool designed to scrape product data from any e-commerce website dataLayer. Users can input one or more URLs, and the scraper will collect product data. Additionally, this scraper can also be used as an API for integration with other systems.
The dataLayer is mostly used in websites being tracked by Google Analytics.

### Table of Contents

- [Getting Started](#getting-started)
- [Use Cases](#use-cases)
- [Legal Compliance](#legal-compliance)

### Getting Started

- Simply add one or multiple url's of the page(s) where you wish to scrape product data from the dataLayer
- If you are not getting any results, it's likely due to a cookie wall. In that case, follow the instructions for adding a css selector to "accept" the cookies
- Click the "All fields" tab to see all the columns of data that have been collected
- **TIP**: Export data (to CSV) to see all the columns of data that have been collected. Apify does not always show all columns on the first page.

### Use Cases

A couple of example use cases for this specific scraper:

- **Price Monitoring**: Keep track of the prices of products across different online retailers for price comparison.

- **Product Catalog Management**: Maintain and update product catalogs by scraping data for product names, descriptions, images, etc.

- **Market Research**: Analyze market trends by examining the types of products being offered by competitors.

- **Inventory Monitoring**: Monitor the availability of products on competitor websites for inventory decisions.

- **Competitor Analysis**: Perform detailed analysis by understanding competitors' product ranges, features, and pricing strategies.

- **Localization**: Inform localization strategy by scraping product data to understand local preferences and competition.

- **Customized Alerts**: Set up notifications when a particular product becomes available or reaches a certain price point.

- **Dropshipping**: Populate online stores with product data from different suppliers for dropshipping.

- **Integration with Business Intelligence Tools**: Integrate with BI tools like Tableau, Power BI, or Google Data Studio for sophisticated data analysis and visualization.

- **Dynamic Pricing Algorithms**: Adjust prices based on competitor pricing and other market factors.

- **Automated Re-pricing for Marketplaces**: Automatically adjust prices on marketplaces like Amazon or eBay based on competitor pricing data.

- **Customized Recommendation Systems**: Enrich product metadata or incorporate competitor data in recommendation systems.

- **Inventory Management Systems**: Automate stock level adjustments based on product availability data scraped from suppliers.

- **Mobile Applications**: Display real-time product data, price comparisons, and availability information in mobile applications.

- **Supply Chain Optimization**: Optimize procurement decisions based on scraped product data and pricing information.

- **Alerts and Reporting Systems**: Generate automated reports and alerts based on product data changes or thresholds.

- **Customer Insights and Personalization**: Derive insights for personalized marketing campaigns and customer experiences by analyzing scraped data.

- **Academic Research and Data Science Projects**: Collect data for academic research and data science projects.

- **Integration with CRM Systems**: Provide sales teams with updated product information and pricing through integration with CRM systems.

### Legal Compliance

Please ensure compliance with the website’s terms of service, robots.txt file, and any applicable laws such as GDPR or local data protection regulations. Respect user privacy and do not violate any laws or regulations. Be mindful of the server load you are causing by your scraping; don't overwhelm the websites with too many requests in a short period.

# Actor input Schema

## `start_urls` (type: `array`):

List of pages (from the same website) that you wish to scrape the product data from

## `cookie_accept` (type: `string`):

Some websites only create the dataLayer object after cookies have been accepted. If your scrape results in zero output, then that's likely the case.

1. Open the website you wish to scrape in INCOGNITO.
2. Right- click on 'accept' button of cookie wall and click 'inspect element'.
3. Right- click on the highlighted element and Copy (css) selector.
4. Paste it in below field.

## Actor input object example

```json
{
  "start_urls": [
    {
      "url": "https://shop.merch.google/shop/lifestyle/drinkware"
    }
  ],
  "cookie_accept": "none"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "start_urls": [
        {
            "url": "https://shop.merch.google/shop/lifestyle/drinkware"
        }
    ],
    "cookie_accept": "none"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eloquent_mountain/scrape-product-data-from-any-e-commerce-site").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "start_urls": [{ "url": "https://shop.merch.google/shop/lifestyle/drinkware" }],
    "cookie_accept": "none",
}

# Run the Actor and wait for it to finish
run = client.actor("eloquent_mountain/scrape-product-data-from-any-e-commerce-site").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "start_urls": [
    {
      "url": "https://shop.merch.google/shop/lifestyle/drinkware"
    }
  ],
  "cookie_accept": "none"
}' |
apify call eloquent_mountain/scrape-product-data-from-any-e-commerce-site --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eloquent_mountain/scrape-product-data-from-any-e-commerce-site"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/2FKDPOmmu7Rbe7gM5/builds/zLIeOHOJ6DRet1MIB/openapi.json
