26. GSC Analytics Helpers (SF-117) | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

26. GSC Analytics Helpers (SF-117)

Developer Guide

Two helpers on SEOFORGE_GSC expose the Rankings page KPIs directly so external tooling / custom dashboards can reuse the same data shape.

get_site_totals(int $days = 28, bool $compare = true): ?array

Aggregate site-wide totals over the given window, optionally with period-over-period comparison against the previous window.

php
$gsc = SEOFORGE_GSC::instance();
$totals = $gsc->get_site_totals(28, true);

// Returns:
// [
//   'period_days' => 28,
//   'current'  => [ 'clicks' => 1234, 'impressions' => 50000, 'ctr' => 2.47, 'position' => 18.4 ],
//   'previous' => [ 'clicks' => 1012, 'impressions' => 44000, 'ctr' => 2.30, 'position' => 20.1 ],
//   'delta'    => [ 'clicks' => 21.9, 'impressions' => 13.6, 'ctr' => 7.4, 'position' => 1.7 ]
// ]
delta.position is an absolute delta in positions (previous − current) — positive means the average position improved (i.e. the site moved up).

Returns null if no GSC property is set or the API call failed.

get_striking_distance_keywords(int $days = 28, int $limit = 25): array

Queries ranking at positions 10.5–15.5 over the given window, aggregated by (query, page) and sorted by impressions DESC.

php
$rows = SEOFORGE_GSC::instance()->get_striking_distance_keywords(28, 25);
foreach ($rows as $row) {
    printf("%s · %s · pos=%.1f · imps=%dn", $row['keyword'], $row['page'], $row['position'], $row['impressions']);
}

Each row: { keyword, page, clicks, impressions, ctr, position }.

Forge AI Assistant Online

Hi! I'm the SEO Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs