|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.dmurph.tracking.JGoogleAnalyticsTracker
public class JGoogleAnalyticsTracker
Common tracking calls are implemented as methods, but if you want to control
what data to send, then use makeCustomRequest(AnalyticsRequestData).
If you are making custom calls, the only requirements are:
AnalyticsRequestData.setEventCategory(String) and
AnalyticsRequestData.setEventAction(String) must both be populated.AnalyticsRequestData.setPageURL(String) must be populatedThe tracker can operate in three modes:
To halt the background thread safely, use the call stopBackgroundThread(long), where the parameter is the
timeout to wait for any remaining queued tracking calls to be made. Keep in mind that if new tracking requests are made
after the thread is stopped, they will just be stored in the queue, and will not be sent to GA until the thread is started again with
startBackgroundThread() (This is assuming you are in single-threaded mode to begin with).
| Nested Class Summary | |
|---|---|
static class |
JGoogleAnalyticsTracker.DispatchMode
|
static class |
JGoogleAnalyticsTracker.GoogleAnalyticsVersion
|
| Constructor Summary | |
|---|---|
JGoogleAnalyticsTracker(AnalyticsConfigData argConfigData,
JGoogleAnalyticsTracker.GoogleAnalyticsVersion argVersion)
|
|
JGoogleAnalyticsTracker(AnalyticsConfigData argConfigData,
JGoogleAnalyticsTracker.GoogleAnalyticsVersion argVersion,
JGoogleAnalyticsTracker.DispatchMode argMode)
|
|
| Method Summary | |
|---|---|
static void |
completeBackgroundTasks(long timeoutMillis)
Wait for background tasks to complete. |
JGoogleAnalyticsTracker.DispatchMode |
getDispatchMode()
Gets the current dispatch mode. |
boolean |
isEnabled()
If the api is dispatching tracking requests (default of true). |
boolean |
isMultiThreaded()
Convenience method to check if the tracker is in multi-thread mode |
boolean |
isSingleThreaded()
Convenience method to check if the tracker is in single-thread mode |
boolean |
isSynchronous()
Convenience method to check if the tracker is in synchronous mode. |
void |
makeCustomRequest(AnalyticsRequestData argData)
Makes a custom tracking request based from the given data. |
void |
resetSession()
Resets the session cookie. |
void |
setDispatchMode(JGoogleAnalyticsTracker.DispatchMode argMode)
Sets the dispatch mode |
void |
setEnabled(boolean argEnabled)
Sets if the api dispatches tracking requests. |
static void |
setProxy(Proxy argProxy)
Define the proxy to use for all GA tracking requests. |
static void |
setProxy(String proxyAddr)
Define the proxy to use for all GA tracking requests. |
static void |
stopBackgroundThread(long timeoutMillis)
Stop the long-lived background thread. |
void |
trackEvent(String argCategory,
String argAction)
Tracks an event. |
void |
trackEvent(String argCategory,
String argAction,
String argLabel)
Tracks an event. |
void |
trackEvent(String argCategory,
String argAction,
String argLabel,
Integer argValue)
Tracks an event. |
void |
trackPageView(String argPageURL,
String argPageTitle,
String argHostName)
Tracks a page view. |
void |
trackPageViewFromReferrer(String argPageURL,
String argPageTitle,
String argHostName,
String argReferrerSite,
String argReferrerPage)
Tracks a page view. |
void |
trackPageViewFromSearch(String argPageURL,
String argPageTitle,
String argHostName,
String argSearchSource,
String argSearchKeywords)
Tracks a page view. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JGoogleAnalyticsTracker(AnalyticsConfigData argConfigData,
JGoogleAnalyticsTracker.GoogleAnalyticsVersion argVersion)
public JGoogleAnalyticsTracker(AnalyticsConfigData argConfigData,
JGoogleAnalyticsTracker.GoogleAnalyticsVersion argVersion,
JGoogleAnalyticsTracker.DispatchMode argMode)
| Method Detail |
|---|
public void setDispatchMode(JGoogleAnalyticsTracker.DispatchMode argMode)
argMode - the mode to to put the tracker in. If this is null, the tracker
defaults to JGoogleAnalyticsTracker.DispatchMode.SINGLE_THREADJGoogleAnalyticsTracker.DispatchModepublic JGoogleAnalyticsTracker.DispatchMode getDispatchMode()
JGoogleAnalyticsTracker.DispatchMode.SINGLE_THREAD.
JGoogleAnalyticsTracker.DispatchModepublic boolean isSynchronous()
public boolean isSingleThreaded()
public boolean isMultiThreaded()
public void resetSession()
public void setEnabled(boolean argEnabled)
argEnabled - public boolean isEnabled()
public static void setProxy(Proxy argProxy)
Call this static method early (before creating any tracking requests).
argProxy - The proxy to usepublic static void setProxy(String proxyAddr)
Call this static method early (before creating any tracking requests).
proxyAddr - "addr:port" of the proxy to use; may also be given as URL ("http://addr:port/").public static void completeBackgroundTasks(long timeoutMillis)
This works in queued and asynchronous mode.
timeoutMillis - The maximum number of milliseconds to wait.
public void trackPageView(String argPageURL,
String argPageTitle,
String argHostName)
argPageURL - required, Google won't track without it. Ex:
"org/me/javaclass.java", or anything you want as
the page url.argPageTitle - content titleargHostName - the host name for the url
public void trackPageViewFromReferrer(String argPageURL,
String argPageTitle,
String argHostName,
String argReferrerSite,
String argReferrerPage)
argPageURL - required, Google won't track without it. Ex:
"org/me/javaclass.java", or anything you want as
the page url.argPageTitle - content titleargHostName - the host name for the urlargReferrerSite - site of the referrer. ex, www.dmurph.comargReferrerPage - page of the referrer. ex, /mypage.php
public void trackPageViewFromSearch(String argPageURL,
String argPageTitle,
String argHostName,
String argSearchSource,
String argSearchKeywords)
argPageURL - required, Google won't track without it. Ex:
"org/me/javaclass.java", or anything you want as
the page url.argPageTitle - content titleargHostName - the host name for the urlargSearchSource - source of the search engine. ex: googleargSearchKeywords - the keywords of the search. ex: java google analytics tracking
utility
public void trackEvent(String argCategory,
String argAction)
makeCustomRequest(AnalyticsRequestData).
argCategory - argAction -
public void trackEvent(String argCategory,
String argAction,
String argLabel)
makeCustomRequest(AnalyticsRequestData).
argCategory - argAction - argLabel -
public void trackEvent(String argCategory,
String argAction,
String argLabel,
Integer argValue)
makeCustomRequest(AnalyticsRequestData).
argCategory - requiredargAction - requiredargLabel - optionalargValue - optionalpublic void makeCustomRequest(AnalyticsRequestData argData)
argData -
NullPointerException - if argData is null or if the URL builder is nullpublic static void stopBackgroundThread(long timeoutMillis)
This method is needed for debugging purposes only. Calling it in an application is not really required: The background thread will terminate automatically when the application exits.
timeoutMillis - If nonzero, wait for thread completion before returning.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||