com.brsanthu.googleanalytics.request.EventHit Maven / Gradle / Ivy
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brsanthu.googleanalytics.request;
import static com.brsanthu.googleanalytics.internal.Constants.HIT_EVENT;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.EVENT_ACTION;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.EVENT_CATEGORY;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.EVENT_LABEL;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.EVENT_VALUE;
/**
* GA request to track events.
*
*
* For more information, see
* GA Parameters
* Reference
*
*
* @author Santhosh Kumar
*/
public class EventHit extends GoogleAnalyticsRequest {
public EventHit() {
this(null, null, null, null);
}
public EventHit(String eventCategory, String eventAction) {
this(eventCategory, eventAction, null, null);
}
public EventHit(String eventCategory, String eventAction, String eventLabel, Integer eventValue) {
super(HIT_EVENT);
eventCategory(eventCategory);
eventAction(eventAction);
eventLabel(eventLabel);
eventValue(eventValue);
}
/**
* Event Tracking
*
* Optional.
*
*
* Specifies the event category. Must not be empty.
*
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ec
* text
* None
* 150 Bytes
* event
*
*
*
* Example value: Category
* Example usage: ec=Category
*/
public EventHit eventCategory(String value) {
setString(EVENT_CATEGORY, value);
return this;
}
public String eventCategory() {
return getString(EVENT_CATEGORY);
}
/**
*
*
* Optional.
*
*
* Specifies the event action. Must not be empty.
*
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ea
* text
* None
* 500 Bytes
* event
*
*
*
* Example value: Action
* Example usage: ea=Action
*/
public EventHit eventAction(String value) {
setString(EVENT_ACTION, value);
return this;
}
public String eventAction() {
return getString(EVENT_ACTION);
}
/**
*
*
* Optional.
*
*
* Specifies the event label.
*
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* el
* text
* None
* 500 Bytes
* event
*
*
*
* Example value: Label
* Example usage: el=Label
*/
public EventHit eventLabel(String value) {
setString(EVENT_LABEL, value);
return this;
}
public String eventLabel() {
return getString(EVENT_LABEL);
}
/**
*
*
* Optional.
*
*
* Specifies the event value. Values must be non-negative.
*
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ev
* integer
* None
* None
* event
*
*
*
* Example value: 55
* Example usage: ev=55
*/
public EventHit eventValue(Integer value) {
setInteger(EVENT_VALUE, value);
return this;
}
public Integer eventValue() {
return getInteger(EVENT_VALUE);
}
}