Meta tags:
description= Combine the overview and metric endpoints into a scheduled digest that summarizes last week s traffic, the week-over-week change, and your top pages and traffic sources.;
author= Rybbit Team;
keywords= web analytics,privacy analytics,open source analytics,Google Analytics alternative,website tracking,self-hosted analytics;
Headings (most frequently used words):
automated, weekly, report, the, workflow, full, script, example, output, schedule, it, next, steps, on, this, page,
Text of the page (most frequently used words):
the (21), users (19), now (17), const (17), sessions (16), change (16), return (16), pageviews (15), overview (13), data (13), and (11), api (11), report (11), top (10), value (10), ymd (10), weekly (9), get (9), function (9), for (8), rybbit (8), arrow (8), def (8), this_week (8), previous (8), end (8), start (8), thisweek (8), sources (7), slack_webhook (7), metric (7), res (7), date (7), week (7), path (6), pages (6), new (6), endpoints (5), topmetric (5), json (5), days (5), limit (5), parameter (5), params (5), session (5), fetch (5), await (5), tolocalestring (5), async (5), thisweekstart (5), script (4), this (4), you (4), traffic (4), endpoint (4), analytics (4), lines (4), count (4), bounce_rate (4), this_start (4), last_week (4), pct_change (4), timedelta (4), datetime (4), current (4), time_zone (4), end_date (4), start_date (4), site (4), api_key (4), lastweek (4), pctchange (4), url (4), last (4), automated (4), schedule (3), example (3), where (3), getting (3), started (3), your (3), events (3), channel (3), performance (3), same (3), with (3), https (3), slack (3), com (3), rybbit_api_key (3), every (3), direct (3), bounce (3), rate (3), unique (3), requests (3), post (3), else (3), top_metric (3), sites (3), headers (3), import (3), buildreport (3), topsources (3), toppages (3), lastweekstart (3), lastweekend (3), getdate (3), setdate (3), can (3), digest (3), that (3), github (3), next (2), steps (2), output (2), full (2), workflow (2), then (2), find (2), drop (2), off (2), authentication (2), parameters (2), build (2), compare (2), marketing (2), add (2), time (2), monday (2), run (2), cron (2), post_to_slack (2), build_report (2), join (2), text (2), top_sources (2), top_pages (2), abs (2), none (2), referrer (2), pathname (2), last_start (2), last_end (2), 100 (2), nests (2), results (2), under (2), str (2), bearer (2), authorization (2), america (2), new_york (2), environ (2), 123 (2), app (2), from (2), error (2), posttoslack (2), map (2), tofixed (2), bouncerate (2), sign (2), null (2), format (2), process (2), env (2), posts (2), anywhere (2), before (2), 687 (2), reference (2), page, chain, funnel, analysis, journeys, locate, biggest, leak, conversion, flow, discover, who, abandon, actually, instead, common, best, practices, stats, rather, reports, own, tool, export, raw, warehouse, beyond, counts, rank, how, well, they, convert, pattern, extends, naturally, channels, geography, call, attach, point, trend, line, bucket, day, series, country, want, richer, node, hooks, xxx, crontab, morning, twitter, 180, 220, google, 410, blog, 940, pricing, 120, 230, 933, 847, 420, utcnow, not, raise_for_status, strftime, weekly_report, console, catch, stringify, body, application, content, type, method, math, all, promise, status, failed, throw, set, searchparams, foreach, entries, object, slice, toisostring, helper, yyyy, python, javascript, formatted, message, incoming, webhook, but, returns, plain, route, deliver, context, compute, takes, trick, behind, any, comparison, simply, calling, twice, two, adjacent, ranges, headline, metrics, range, used, guide, builds, job, action, serverless, pulls, numbers, compares, them, email, open, copy, markdown, combine, into, scheduled, summarizes, over, keys, imports, teams, organizations, management, insights, bots, errors, funnels, goals, user, traits, replay, sending, live, visitor, feed, guides, rest, documentation, search,
Text of the page (random words):
automated weekly report rybbit search k github rybbit io rybbit 12 4k 687 documentation api reference api reference rest api endpoints and authentication github rybbit io rybbit 12 4k 687 getting started guides automated weekly report find where users drop off compare channel performance build a live visitor feed endpoints sending events post overview sessions session replay users user traits events goals funnels performance errors bots insights management organizations teams sites imports api keys automated weekly report automated weekly report combine the overview and metric endpoints into a scheduled digest that summarizes last week s traffic the week over week change and your top pages and traffic sources copy markdown open this guide builds a script you can run on a schedule a cron job github action or serverless function that pulls last week s numbers compares them to the week before and posts a digest to slack email or anywhere else endpoints used get overview headline metrics for a date range get metric top pages and traffic sources every analytics endpoint takes the same time parameters the trick behind any comparison report is simply calling the same endpoint twice with two adjacent date ranges the workflow fetch this week s overview for the last 7 days fetch last week s overview for the 7 days before that so you can compute the change fetch top pages and top sources from the metric endpoint to add context format and deliver the digest full script this example posts a formatted message to a slack incoming webhook but the buildreport function returns plain data you can route anywhere javascript python weekly report js const api https app rybbit io const site 123 const api_key process env rybbit_api_key const slack_webhook process env slack_webhook const tz america new_york helper format a date as yyyy mm dd const ymd d d toisostring slice 0 10 async function get path params const url new url api api sites site path object entries params foreach k v url searchparams set k v const res await fetch url headers authorization bearer api_key if res ok throw new error path failed res status return res json async function overview start end const data await get overview start_date ymd start end_date ymd end time_zone tz return data async function topmetric parameter start end limit 5 const data await get metric parameter start_date ymd start end_date ymd end time_zone tz limit return data data metric nests results under data data function pctchange current previous if previous return null return current previous previous 100 async function buildreport const now new date const thisweekstart new date now thisweekstart setdate now getdate 7 const lastweekend new date now lastweekend setdate now getdate 8 const lastweekstart new date now lastweekstart setdate now getdate 14 const thisweek lastweek toppages topsources await promise all overview thisweekstart now overview lastweekstart lastweekend topmetric pathname thisweekstart now topmetric referrer thisweekstart now return sessions value thisweek sessions change pctchange thisweek sessions lastweek sessions users value thisweek users change pctchange thisweek users lastweek users pageviews value thisweek pageviews change pctchange thisweek pageviews lastweek pageviews bouncerate thisweek bounce_rate toppages topsources function arrow change if change null return const sign change 0 return sign math abs change tofixed 1 async function posttoslack r const lines weekly analytics report sessions r sessions value tolocalestring arrow r sessions change unique users r users value tolocalestring arrow r users change pageviews r pageviews value tolocalestring arrow r pageviews change bounce rate r bouncerate tofixed 1 top pages r toppages map p p value p count tolocalestring top sources r topsources map s s value direct s count tolocalestring await fetch slack_webhook method post headers content type application json body json stringify text lines join n buildreport then posttoslack catch console error weekly_report py import os from datetime import datetime timedelta import requests api https app rybbit io site 123 api_key os environ rybbit_api_key slack_webhook os environ slack_webhook tz america new_york session requests session session headers authorization f bearer api_key def ymd d datetime str return d strftime y m d def get path str params res session get f api api sites site path params params res raise_for_status return res json def overview start end return get overview start_date ymd start end_date ymd end time_zone tz data def top_metric parameter start end limit 5 metric nests results under data data return get metric parameter parameter start_date ymd start end_date ymd end time_zone tz limit limit data data def pct_change current previous return none if not previous else current previous previous 100 def build_report now datetime utcnow this_start now timedelta days 7 last_end now timedelta days 8 last_start now timedelta days 14 this_week overview this_start now last_week overview last_start last_end return sessions this_week sessions pct_change this_week sessions last_week sessions users this_week users pct_change this_week users last_week users pageviews this_week pageviews pct_change this_week pageviews last_week pageviews bounce_rate this_week bounce_rate top_pages top_metric pathname this_start now top_sources top_metric referrer this_start now def arrow change if change is none return return f if change 0 else abs change 1f def post_to_slack r lines weekly analytics report f sessions r sessions 0 arrow r sessions 1 f unique users r users 0 arrow r users 1 f pageviews r pageviews 0 arrow r pageviews 1 f bounce rate r bounce_rate 1f top pages f p value p count for p in r top_pages top sources f s value or direct s count for s in r top_sources requests post slack_webhook json text n join lines post_to_slack build_report example output weekly analytics report sessions 15 420 12 3 unique users 12 847 9 8 pageviews 48 933 2 1 bounce rate 42 8 top pages 8 230 pricing 3 120 blog getting started 1 940 top sources google com 6 410 direct 4 220 twitter com 1 180 schedule it run the script every monday morning with cron crontab e every monday at 9 00 am 0 9 1 rybbit_api_key xxx slack_webhook https hooks slack com node path to weekly report js want a richer report the same pattern extends naturally add topmetric channel for marketing channels topmetric country for geography or call the time series endpoint with bucket day to attach a 7 point trend line next steps compare marketing channel performance go beyond traffic counts and rank sources by how well they convert export raw events to your warehouse if you d rather build reports in your own bi tool getting started authentication common parameters and best practices for the rybbit stats api find where users drop off chain the funnel analysis and journeys endpoints to locate the biggest leak in a conversion flow then discover where the users who abandon actually go instead on this page the workflow full script example output schedule it next steps
|