com.brsanthu.googleanalytics.SocialHit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of google-analytics-java Show documentation
Show all versions of google-analytics-java Show documentation
This is Java API for Google Analytics (Measurement Protocol). More information about the protocol is available at https://developers.google.com/analytics/devguides/collection/protocol/v1/.
/*
* 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;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.SOCIAL_ACTION;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.SOCIAL_ACTION_TARGET;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.SOCIAL_NETWORK;
/**
* GA request to track social interactions
*
* For more information, see GA Parameters Reference
*
* @author Santhosh Kumar
*/
public class SocialHit extends GoogleAnalyticsRequest {
public SocialHit() {
this(null, null, null);
}
public SocialHit(String socialNetwork, String socialAction, String socialTarget) {
super("social");
socialAction(socialAction);
socialNetwork(socialNetwork);
socialActionTarget(socialTarget);
}
/**
*
*
* Required for social hit type.
*
* Specifies the social network, for example Facebook or Google Plus.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* sn
* text
* None
*
* 50 Bytes
*
* social
*
*
*
*
* Example value: facebook
* Example usage: sn=facebook
*
*
*/
public SocialHit socialNetwork(String value) {
setString(SOCIAL_NETWORK, value);
return this;
}
public String socialNetwork() {
return getString(SOCIAL_NETWORK);
}
/**
*
*
* Required for social hit type.
*
* Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* sa
* text
* None
*
* 50 Bytes
*
* social
*
*
*
*
* Example value: like
* Example usage: sa=like
*
*
*/
public SocialHit socialAction(String value) {
setString(SOCIAL_ACTION, value);
return this;
}
public String socialAction() {
return getString(SOCIAL_ACTION);
}
/**
*
*
* Required for social hit type.
*
* Specifies the target of a social interaction. This value is typically a URL but can be any text.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* st
* text
* None
*
* 2048 Bytes
*
* social
*
*
*
*
* Example value: http://foo.com
* Example usage: st=http%3A%2F%2Ffoo.com
*
*
*/
public SocialHit socialActionTarget(String value) {
setString(SOCIAL_ACTION_TARGET, value);
return this;
}
public String socialActionTarget() {
return getString(SOCIAL_ACTION_TARGET);
}
}