0

Integrate Google Analytics?

asked 2018-06-29 05:07:57 +0800

davout gravatar image davout
1435 3 18

Any suggestions for how best to integrate a ZK MVVM web UI with Google Analytics?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-06-29 12:06:48 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

updated 2018-06-29 12:08:27 +0800

Hi Davout!

Depends what you are planning to track. If you just want the plain old page count, just add the GA initialization code (from GA console) globally in your application, and add a ga('send', 'pageview') call in the same script. Global JS code can be deployed from zk.xml or from lang-addon.xml (I would recommend lang-addon as it's easier to declare a js file located somewhere in your project)

If you want to do more complicated stuff (like sending events on specific actions), there is no "one-size-fits-all" solution. The approach will depend on the action and timing. Edit: in any case, global init from lang-addon will still be a good start, since you will need the GA object initialized on client side when you are ready to send anything.

link publish delete flag offensive edit
0

answered 2018-07-02 05:03:18 +0800

davout gravatar image davout
1435 3 18

I've found that GA has a Java client library that can be used to post events. My intention is to add a call to GA as the final step in each MVVM class event handler method. Sound right?

link publish delete flag offensive edit

Comments

Sounds good. If you are using the Java client for GA, then there is no need for integration code. Since you can call the Library directly, it just become a matter of selecting the events that should trigger a GA action in your business code / view models.

MDuchemin ( 2018-07-02 09:27:03 +0800 )edit

You could also consider registering a single view model at page root (GaViewModel or eq), and send global commands to that VM whenever something happen in the page which requires pushing info to GA

MDuchemin ( 2018-07-02 09:29:26 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2018-06-29 05:07:57 +0800

Seen: 13 times

Last updated: Jul 02 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More