Analytics & SEO Tools
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Analytics & SEO Tools module within the "WhereIsLifeCheaper" project provides a comprehensive suite for search engine optimization and site monitoring. Its primary purpose is to ensure the platform remains discoverable across diverse markets by dynamically managing metadata, structured data, and sitemaps based on real-time grocery price data.
This system handles multi-language support (English, Russian, Ukrainian), robots directives, and JSON-LD schema generation to improve rankings for country-specific grocery price comparisons. Sources: frontend/src/hooks/useSEO.ts, src/api/routes/sitemap.ts, frontend/src/i18n/locales/en.json
SEO Management Architecture
The project utilizes a React hook-based architecture to manage on-page SEO dynamically. This allows the application to update document titles, meta tags, and structured data scripts as users navigate between country-specific pages or search results.
Dynamic Meta Tag Management
The useSEO hook serves as the central controller for document head updates. It manages standard meta tags (description, keywords), Open Graph (OG) tags for social sharing, and Twitter Card tags.
The diagram above illustrates the lifecycle of SEO metadata during component navigation. Sources: frontend/src/hooks/useSEO.ts:25-132
Technical Implementation Details
The useSEO hook accepts a SEOProps interface to define page-specific metadata:
| Field | Type | Description | Default |
|---|---|---|---|
title | string | Page title suffix | "WhereIsLifeCheaper - Compare Grocery..." |
description | string | Meta description | "Compare grocery prices across countries..." |
ogType | 'website' | 'article' | 'product' | Open Graph type | 'website' |
noIndex | boolean | Robots indexing directive | false |
structuredData | object | JSON-LD object | undefined |
Sources: frontend/src/hooks/useSEO.ts:3-23
Structured Data (JSON-LD)
The system generates specific schemas to help search engines understand the content hierarchy. This includes website-level search actions, country-level product summaries, and navigational breadcrumbs.
Schema Generation Functions
The application includes specialized generators for different page types:
- Website Schema: Includes a
SearchActiontargeting the main search functionality. Sources: frontend/src/hooks/useSEO.ts:135-151 - Country Schema: Defines the
WebPageas being "about" a specificCountrywith product counts. Sources: frontend/src/hooks/useSEO.ts:154-173 - Breadcrumb Schema: Constructs a
BreadcrumbListfor site hierarchy. Sources: frontend/src/hooks/useSEO.ts:176-189 - FAQ Schema: Generates
FAQPagedata for common user queries. Sources: frontend/src/hooks/useSEO.ts:192-205
Discoverability & Sitemaps
The backend provides dynamic endpoints to facilitate crawling by major search engines (Google, Bing, DuckDuckGo, Yandex).
Sitemap Generation Flow
The /sitemap.xml route queries the database for all active countries to build a localized URL set.
The generator includes xhtml:link tags for multi-language alternates (en, ru, uk). Sources: src/api/routes/sitemap.ts:10-70
Robots.txt Configuration
The project serves a dynamic robots.txt that explicitly allows major bots while protecting administrative and internal API routes.
| Directive | Path | Reason |
|---|---|---|
Allow | / | General site access |
Disallow | /admin/ | Security of management panel |
Disallow | /login | Authentication protection |
Disallow | /api/ | Internal data structures |
Sitemap | /sitemap.xml | Indexing entry point |
Sources: src/api/routes/sitemap.ts:74-100
Analytics & Monitoring Tools
While SEO focuses on external visibility, the project includes internal monitoring through a Scraper API and Logging system.
Scraper Status Monitoring
The system tracks the health of data collection, which directly impacts SEO freshness. The scraperApi provides status updates used in the admin dashboard.
- Stats 24h: Monitors success/failure rates and total products scraped.
- Recent Logs: Captures errors and durations for audit trails.
Sources: frontend/src/services/api.ts:133-157, plan.md:65-72
Logging Integration
The system utilizes Winston and Google Cloud Logging to maintain a technical audit trail of application performance and scraping success. Sources: README.md:16, package.json:49
Conclusion
The Analytics & SEO Tools in WhereIsLifeCheaper represent a bridge between data collection and user acquisition. By leveraging dynamic React hooks for metadata and database-driven sitemap generation, the system ensures that up-to-date grocery prices from ten different countries remain highly visible to search engines and social platforms. Sources: README.md:8-14, frontend/src/hooks/useSEO.ts