Hi together,
I have a problem with Vaadin (13.0.1) and the addon from https://vaadin.com/directory/component/googleanalyticstracker too.
What I wanted to achieve is to count people visiting my website and log hits on my login button on my login page for the beginning.
So I added
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>googleanalyticstracker</artifactId>
<version>4.0.0</version>
</dependency>
to my pom.xml
My Loginpage looks like:
@Route(value = "login")
@Caption("Home")
@Icon(VaadinIcon.HOME)
@EnableGoogleAnalytics(value = "UA-ABCDE-1")
public class LoginScreen extends VerticalLayout implements TrackerConfigurator, LocaleChangeObserver, BeforeEnterObserver {
private LoginService loginService;
private LoginForm loginForm;
@Autowired
public LoginScreen(LoginService loginService) {
if (VaadinSession.getCurrent().getAttribute(Benutzer.class) != null) {
return;
}
this.loginService = loginService;
loginForm = new LoginForm();
loginForm.addLoginListener((ComponentEventListener<AbstractLogin.LoginEvent>) event -> {
final String username = event.getUsername();
GoogleAnalyticsTracker.getCurrent().sendEvent("Login", "Login try (User: " + username + ")");
............
});
loginForm.setForgotPasswordButtonVisible(false);
add(loginForm);
}
@Override
public void localeChange(LocaleChangeEvent event) {
loginForm.setI18n(updateLocale());
}
private LoginI18n updateLocale() {
.................
}
@Override
public void beforeEnter(BeforeEnterEvent event) {
if (VaadinSession.getCurrent().getAttribute(Benutzer.class) != null) {
event.rerouteTo("");
}
}
@Override
public void configureTracker(TrackerConfiguration trackerConfiguration) {
trackerConfiguration.setCreateField("allowAnchor", Boolean.FALSE);
trackerConfiguration.setInitialValue("transport", "beacon");
trackerConfiguration.setCookieDomain("none");
}
}
Now when running the app (localhost:8080/login) the google tag assistant finds the tag but says:
“No HTTP response detected” and “Missing analytics.js script”.
(It says the same when running the example from github)
But in the dev tools I can see:
client-28831013082792340517B7074033EF04.cache.js:183 Processing time was 0ms
analytics_debug.js:24
_ _ _ _
| | | | | | (_)
__ _ ___ ___ __ _| | ___ __ _ _ __ __ _| |_ _| |_ _ ___ ___
/ _` |/ _ \ / _ \ / _` | |/ _ \ / _` | '_ \ / _` | | | | | __| |/ __/ __|
| (_| | (_) | (_) | (_| | | __/ | (_| | | | | (_| | | |_| | |_| | (__\__ \
\__, |\___/ \___/ \__, |_|\___| \__,_|_| |_|\__,_|_|\__, |\__|_|\___|___/
__/ | __/ | __/ |
|___/ |___/ |___/
analytics_debug.js:24 Running analytics_debug.js. This script is intended for testing and debugging only.
log @ analytics_debug.js:24
analytics_debug.js:24 Initializing Google Analytics.
analytics_debug.js:24 Running command: ga("create", "UA-ABCDE-1", "none", {allowAnchor: false})
analytics_debug.js:24 Creating new tracker: t0
analytics_debug.js:24 New visitor. Generating new clientId
analytics_debug.js:24 Generating new gid
analytics_debug.js:24 Running command: ga("set", {sendHitTask: null, transport: "beacon"})
analytics_debug.js:24 Running command: ga("set", "page", "login")
analytics_debug.js:24 Running command: ga("send", "pageview")
analytics_debug.js:24 Setting throttling cookie: "_gat"
analytics_debug.js:24 Registered new plugin: ga(provide, "render", Function)
client-28831013082792340517B7074033EF04.cache.js:183 Loaded https://www.google-analytics.com/analytics_debug.js
And even if I hit the button I see the corresponding GA-Code executed in the dev tools (see attached screenshot).
But my real time dashboard of GA always shows 0 visitors. Am I missing something here? Any help appreciated. Thanks a lot in advance!