Here's a simple example for how to use the annotation version of the add-on

Here’s a simple example for how to use the annotation version of the add-on on Vaadin 10+. Put the annotation on your root RouterLayout.

@EnableGoogleAnalytics(value = "UA-xxxxxxxx-x", sendMode = SendMode.ALWAYS)
public class MainLayout extends Div implements RouterLayout, TrackerConfigurator {
  @Value("${google.analytics.tracker.cookieDomain}")
  private String analyticsCookieDomain;

  @Override
  public void configureTracker(TrackerConfiguration configuration) {
    configuration.setCookieDomain(analyticsCookieDomain);
  }
}

You can find a complete example here:
https://github.com/samie/vaadin-ga-tracker/tree/master/demo/src/main/java/org/vaadin/googleanalytics/tracking/demo