Skip to content

Instantly share code, notes, and snippets.

@rdwallis
Created February 10, 2015 09:09
Show Gist options
  • Save rdwallis/a4b2e264cea2bcdf4946 to your computer and use it in GitHub Desktop.
Save rdwallis/a4b2e264cea2bcdf4946 to your computer and use it in GitHub Desktop.
GWTP Navigation Tracker
package YOUR_PACKAGE_NAME
import javax.inject.Inject;
import com.arcbees.analytics.shared.Analytics;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.proxy.NavigationEvent;
import com.gwtplatform.mvp.client.proxy.NavigationHandler;
import com.gwtplatform.mvp.shared.proxy.TokenFormatter;
public class NavigationTracker implements NavigationHandler {
private final Analytics analytics;
private final TokenFormatter tokenFormatter;
@Inject
NavigationTracker(TokenFormatter tokenFormatter, EventBus eventBus, Analytics analytics) {
this.analytics = analytics;
this.tokenFormatter = tokenFormatter;
eventBus.addHandler(NavigationEvent.getType(), this);
}
@Override
public void onNavigation(final NavigationEvent navigationEvent) {
analytics.sendPageView().documentPath(tokenFormatter.toPlaceToken(navigationEvent.getRequest())).go();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment