liquid_go_router

GoRouter screen tracking for liquid_analytics — emit a liquid screen event on every route change, with no per-screen instrumentation.

Split out of liquid_analytics_ui in 0.2.0 so the consent banner and inspector no longer force a go_router dependency on apps that do not use it.

Install

dependencies:
  liquid_analytics: ^0.2.0
  liquid_go_router: ^0.2.0
  go_router: ^17.0.0

Use

Two strategies, depending on the screen names you want.

Option A — route names

LiquidGoRouterObserver reports GoRoute.name. Routes without a name are skipped.

final router = GoRouter(
  observers: [LiquidGoRouterObserver(liquid)],
  routes: [
    GoRoute(path: '/', name: 'home', builder: ...),
    GoRoute(path: '/cart', name: 'cart', builder: ...),
  ],
);

Customize with nameExtractor to derive a name however you like:

LiquidGoRouterObserver(
  liquid,
  nameExtractor: (route) => route.settings.name?.toUpperCase(),
);

Option B — matched path

LiquidGoRouterBinding reports the full location (/product/42) instead of a static name. Attach it once after building the router, and detach on dispose.

final binding = LiquidGoRouterBinding(liquid, router)..attach();
// Include `?ref=email` etc. with includeQueryParams: true
// ...
binding.detach();

Consecutive duplicate locations are collapsed, so a rebuild does not emit a second screen event.

Which to choose

Reports Good for
LiquidGoRouterObserver GoRoute.name Stable, low-cardinality screen names
LiquidGoRouterBinding Matched URI path Path-level detail, dynamic segments

Screen events flow through the normal liquid pipeline, so middleware and the consent gate apply exactly as they do to track.

Not using GoRouter?

liquid_analytics ships LiquidNavigatorObserver for plain Navigator apps — no extra package required.

Libraries

liquid_go_router
GoRouter screen tracking for liquid_analytics.