|
@@ -81,6 +81,8 @@
|
|
|
|
|
|
|
|
+ (void)trackProduct:(NSString *)productName action:(NSString *)action count:(NSNumber *)count{
|
|
+ (void)trackProduct:(NSString *)productName action:(NSString *)action count:(NSNumber *)count{
|
|
|
|
|
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
+
|
|
|
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
|
|
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
|
|
|
|
|
|
|
|
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
|
|
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
|
|
@@ -99,17 +101,41 @@
|
|
|
}
|
|
}
|
|
|
GAIEcommerceProductAction *paction = [[GAIEcommerceProductAction alloc] init];
|
|
GAIEcommerceProductAction *paction = [[GAIEcommerceProductAction alloc] init];
|
|
|
if ([action isEqualToString:@"Add To Cart"]) {
|
|
if ([action isEqualToString:@"Add To Cart"]) {
|
|
|
|
|
+
|
|
|
[paction setAction:kGAIPAAdd];
|
|
[paction setAction:kGAIPAAdd];
|
|
|
|
|
+ // 自定义指标 Add To Cart
|
|
|
|
|
+ NSString *metricValue4 = @"1";
|
|
|
|
|
+ [tracker set:[GAIFields customMetricForIndex:4] value:metricValue4]; //
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
[paction setAction:kGAIPADetail];
|
|
[paction setAction:kGAIPADetail];
|
|
|
|
|
+
|
|
|
|
|
+ // 自定义指标 View A Model
|
|
|
|
|
+ NSString *metricValue3 = @"1";
|
|
|
|
|
+ [tracker set:[GAIFields customMetricForIndex:3] value:metricValue3]; //
|
|
|
}
|
|
}
|
|
|
[builder setProductAction:paction];
|
|
[builder setProductAction:paction];
|
|
|
|
|
|
|
|
|
|
+ // 自定义维度
|
|
|
|
|
+ NSString *dimensionValue1 = productName;
|
|
|
|
|
+ [tracker set:[GAIFields customDimensionForIndex:1] value:dimensionValue1]; // Model Name
|
|
|
|
|
+ NSString *dimensionValue2 = appDelegate.user;
|
|
|
|
|
+ [tracker set:[GAIFields customDimensionForIndex:2] value:dimensionValue2]; // User Name
|
|
|
|
|
+ NSString *dimensionValue3 = appDelegate.customerInfo[@"customer_name"];
|
|
|
|
|
+ [tracker set:[GAIFields customDimensionForIndex:3] value:dimensionValue3]; // Customer Name
|
|
|
|
|
|
|
|
|
|
+ //----------------
|
|
|
[tracker send:[builder build]];
|
|
[tracker send:[builder build]];
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)clearTracker {
|
|
|
|
|
+ id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
|
|
|
|
|
+ [tracker set:[GAIFields customMetricForIndex:3] value:nil]; //
|
|
|
|
|
+ [tracker set:[GAIFields customMetricForIndex:4] value:nil];
|
|
|
|
|
+ [tracker set:[GAIFields customDimensionForIndex:1] value:nil];
|
|
|
|
|
+// [tracker set:[GAIFields customDimensionForIndex:2] value:nil];
|
|
|
|
|
+// [tracker set:[GAIFields customDimensionForIndex:3] value:nil];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|