在Site Catalyst中,我们定义了自定义流量变量“Item Bought”。现在我如何发送请求从Android库更新此自定义变量?我没有找到太多帮助here
请在下面找到我的代码,
public class TrackingHelper {
private static final String TRACKING_RSID = "MY_TRACKING_RSID";
private static final String TRACKING_SERVER = "MY_TRACKING_SERVER";
static ADMS_Measurement measurement = null;
public static void startActivity(Activity activity) {
measurement = ADMS_Measurement.sharedInstance(activity);
measurement.startActivity(activity);
}
public static void stopActivity() {
measurement = ADMS_Measurement.sharedInstance();
measurement.stopActivity();
}
public static void configureAppMeasurement(Activity activity) {
if (measurement == null) {
measurement = ADMS_Measurement.sharedInstance(activity);
measurement.configureMeasurement(TRACKING_RSID, TRACKING_SERVER);
measurement.setOfflineTrackingEnabled(true);
measurement.setDebugLogging(true);
}
}
public static void trackItemBought() {
if (measurement != null) {
measurement = ADMS_Measurement.sharedInstance();
Hashtable<String, Object> contextData = new Hashtable<String, Object>();
contextData.put("Item Bought", "Item Bought");
measurement.setEvents("Item Bought");
measurement.track(contextData);
}
}
}
答案 0 :(得分:1)
我不能保证安卓代码,但这里有一些一般的想法:
当您发送上下文数据变量时,您发送了一个名称 - 值对,所以我怀疑这一行: contextData.put(“物品买”,“物品买”); 应该是更像这样的东西(我要说的是买的项目是篮球): contextData.put(“物品买”,“篮球”);
然后,有权访问SiteCatalyst中的处理规则的人需要配置一个规则来说明该变量(“物品购买”)属于其分配的自定义流量变量(例如prop14)。 http://www.jasonegan.net/2011/04/07/omniture-sitecatalyst-15-context-variables-processing-rules/讨论了如何做到这一点,但文章通常假设您对SiteCatalyst有一定的知识水平。
答案 1 :(得分:0)
只需在代码中进行以下更改。
public class TrackingHelper {
private static final String TRACKING_RSID = "MY_TRACKING_RSID";
private static final String TRACKING_SERVER = "MY_TRACKING_SERVER";
static ADMS_Measurement measurement = null;
public static void startActivity(Activity activity) {
measurement = ADMS_Measurement.sharedInstance(activity);
measurement.startActivity(activity);
}
public static void stopActivity() {
measurement = ADMS_Measurement.sharedInstance();
measurement.stopActivity();
}
public static void configureAppMeasurement(Activity activity) {
if (measurement == null) {
measurement = ADMS_Measurement.sharedInstance(activity);
measurement.configureMeasurement(TRACKING_RSID, TRACKING_SERVER);
measurement.setOfflineTrackingEnabled(true);
measurement.setDebugLogging(true);
}
}
public static void trackItemBought() {
if (measurement != null) {
measurement = ADMS_Measurement.sharedInstance();
Hashtable<String, Object> contextData = new Hashtable<String, Object>();
contextData.put("Item Bought", "Item Bought");
measurement.setEvents("Item Bought");
measurement.contextData(contextData);
measurement.track();
}
}