This is how you can send events to google analytics from your JavaFX web application using gaforjavafx software. This simple example shows that when a button is pressed in JavaFX an event is sent to your google analytics account.
/* * Main.fx
*
* Created on 19-Jan-2010, 7:35:18 AM
*/
package gaforfx;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import gaforjavafx.*;
var tracker: GATracker = new GATracker();
var accountID = "UA-12345678-9";
Stage {
title: "Application title"
width: 250
height: 80
scene: Scene {
content: [
Button {
text: "gaForJavaFX"
action: function() {
tracker.trackEvent(accountID, "JavaFX", "gaForJavaFX", "JavaFX Button Pressed")
}
}
]
}
}
We created a variable called tracker which is an instance of GATracker from the gaforjavafx package. We then created an accountID variable which contains the string for users assigned google analytics account ID. Finally, in the button's action function we call the trackEvent method of the tracker object passing it values for the accountID, and three strings for the category, action and label respectively. Here is the description of the parameters that can be passed in the trackEvent method.
accountID
Your google analytics account id.
category
The name you supply for the group of objects you want to track.
action
A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.
label (optional)
An optional string to provide additional dimensions to the event data.
value (optional)
An integer that you can use to provide numerical data about the user event.
If you would like to know more about adding Google Analytics tracking to your JavaFX web application using gaforjavafx then contact us at gaforjavafx@gmail.com .
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment