概览
用于构建匹配参数和值的字典的辅助类。
示例:
id<GAITracker> t = // get a tracker. [t send:[[[GAIDictionaryBuilder createEventWithCategory:@"EventCategory" action:@"EventAction" label:nil value:nil] set:"dimension1" forKey:[GAIFields customDimensionForIndex:1]] build]];
这样即可使用指定参数和一个自定义维度参数来发送事件匹配类型。
如果您要将某个参数与所有匹配一起发送,请用 GAITracker 直接设置。
[t set:kGAIScreenName value:@"Home"]; [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" action:@"PlusOne" target:@"SOME_URL"] build]]; [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" action:@"Share" target:@"SOME_POST"] build]]; [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" action:@"HangOut" target:@"SOME_CIRCLE"] build]];
您可以覆盖跟踪器上设置的某个值,方法是将其添加到字典。
[t set:kGAIScreenName value:@"Home"]; [t send:...]; [t send[[[GAIDictionaryBuilder createEventWithCategory:@"click" action:@"popup" label:nil value:nil] set:@"popup title" forKey:kGAIScreenName] build]];
通过 [GAIDictionaryBuilder set] 或 [GAIDictionaryBuilder setAll] 设置的值将覆盖 GAIDictionaryBuilder 对象中的任何现有值(即 [GAIDictionaryBuilder createXYZ] 初始化的值)。例如:
GAIDictionaryBuilder *m = GAIDictionaryBuilder createTimingWithCategory:@"category" interval:@0 name:@"name" label:nil]; [t send:[m.set:@"10" forKey:kGAITimingVar] build]; [t send:[m.set:@"20" forKey:kGAITimingVar] build];
此类继承 NSObject。
实例方法 | |
(GAIDictionaryBuilder *) | - setAll: |
将参数中的所有名-值对复制到此对象中,忽略所有非 NSString 键和所有既非 NSString 也非 NSNull 的值。更多... | |
(NSString *) | - get: |
返回输入参数 paramName 的值,如果 paramName 不存在则返回 nil。更多... | |
(NSMutableDictionary *) | - build |
使用 this 中设置的所有参数,返回一个 NSMutableDictionary 对象。更多... | |
(GAIDictionaryBuilder *) | - setCampaignParametersFromUrl: |
将 Urchin 流量监视器广告系列参数解析和转换为 Google Analytics(分析)广告系列参数,并以映射形式返回这些参数。更多... | |
(GAIDictionaryBuilder *) | - setProductAction: |
设置此匹配的产品操作字段。更多... | |
(GAIDictionaryBuilder *) | - addProduct: |
将一个产品添加到此匹配。更多... | |
(GAIDictionaryBuilder *) | - addProductImpression:impressionList:impressionSource: |
将一次产品展示添加到此匹配。更多... | |
(GAIDictionaryBuilder *) | - addPromotion: |
将一条促销信息添加到此匹配。更多... | |
类方法 | |
(“请改用 createScreenView。”) | + createAppView |
使用特定于应用屏幕浏览匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createScreenView |
使用特定于屏幕浏览匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createEventWithCategory:action:label:value: |
使用特定于事件匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createExceptionWithDescription:withFatal: |
使用特定于异常匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createItemWithTransactionId:name:sku:category:price:quantity:currencyCode: |
使用特定于商品匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createSocialWithNetwork:action:target: |
使用特定于社交匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createTimingWithCategory:interval:name:label: |
使用特定于计时匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
(GAIDictionaryBuilder *) | + createTransactionWithId:affiliation:revenue:tax:shipping:currencyCode: |
使用特定以交易匹配的参数,返回一个 GAIDictionaryBuilder 对象。更多... | |
方法说明
- (GAIDictionaryBuilder *) setAll: | (NSDictionary *) | params |
将参数中的所有名-值对复制到此对象中,忽略所有非 NSString 键和所有既非 NSString 也非 NSNull 的值。
- (NSString *) get: | (NSString *) | paramName |
返回输入参数 paramName 的值,如果 paramName 不存在则返回 nil。
- (NSMutableDictionary *) build |
使用 this 中设置的所有参数,返回一个 NSMutableDictionary 对象。
- (GAIDictionaryBuilder *) setCampaignParametersFromUrl: | (NSString *) | urlString |
将 Urchin 流量监视器广告系列参数解析和转换为 Google Analytics(分析)广告系列参数,并以映射形式返回这些参数。
- 参数
-
参数 url 包含 Urchin 流量监视器广告系列参数。
有效的广告系列参数包括:
- utm_id
- utm_campaign
- utm_content
- utm_medium
- utm_source
- utm_term
- dclid
- gclid
- gmob_t
- aclid
- anid
示例:http://my.site.com/index.html?utm_campaign=wow&utm_source=source utm_campaign=wow&utm_source=source。
有关自动标记和手动标记的详细信息,请参阅自动标记的优势。
+ (GAIDictionaryBuilder *) createAppView |
使用特定于应用屏幕浏览匹配的参数,返回一个 GAIDictionaryBuilder 对象。
请注意,使用此方法不会设置后续匹配的屏幕名称。如果要设置,您需要使用 GAITracker 实例来调用 set:kGAIDescription value:<screenName>。
该方法已弃用。请改用 createScreenView。
+ (GAIDictionaryBuilder *) createScreenView |
使用特定于屏幕浏览匹配的参数,返回一个 GAIDictionaryBuilder 对象。
请注意,使用此方法不会设置后续匹配的屏幕名称。如果要设置,您需要使用 GAITracker 实例来调用 set:kGAIDescription value:<screenName>。
+ (GAIDictionaryBuilder *) createEventWithCategory: | (NSString *) | category | |
action: | (NSString *) | action | |
label: | (NSString *) | label | |
value: | (NSNumber *) | value | |
使用特定于事件匹配的参数,返回一个 GAIDictionaryBuilder 对象。
+ (GAIDictionaryBuilder *) createExceptionWithDescription: | (NSString *) | description | |
withFatal: | (NSNumber *) | fatal | |
使用特定于异常匹配的参数,返回一个 GAIDictionaryBuilder 对象。
+ (GAIDictionaryBuilder *) createItemWithTransactionId: | (NSString *) | transactionId | |
name: | (NSString *) | name | |
sku: | (NSString *) | sku | |
category: | (NSString *) | category | |
price: | (NSNumber *) | price | |
quantity: | (NSNumber *) | quantity | |
currencyCode: | (NSString *) | currencyCode | |
使用特定于商品匹配的参数,返回一个 GAIDictionaryBuilder 对象。
+ (GAIDictionaryBuilder *) createSocialWithNetwork: | (NSString *) | network | |
action: | (NSString *) | action | |
target: | (NSString *) | target | |
使用特定于社交匹配的参数,返回一个 GAIDictionaryBuilder 对象。
+ (GAIDictionaryBuilder *) createTimingWithCategory: | (NSString *) | category | |
interval: | (NSNumber *) | intervalMillis | |
name: | (NSString *) | name | |
label: | (NSString *) | label | |
使用特定于计时匹配的参数,返回一个 GAIDictionaryBuilder 对象。
+ (GAIDictionaryBuilder *) createTransactionWithId: | (NSString *) | transactionId | |
affiliation: | (NSString *) | affiliation | |
revenue: | (NSNumber *) | revenue | |
tax: | (NSNumber *) | tax | |
shipping: | (NSNumber *) | shipping | |
currencyCode: | (NSString *) | currencyCode | |
使用特定以交易匹配的参数,返回一个 GAIDictionaryBuilder 对象。
- (GAIDictionaryBuilder *) setProductAction: | (GAIEcommerceProductAction *) | productAction |
设置此匹配的产品操作字段。
- (GAIDictionaryBuilder *) addProduct: | (GAIEcommerceProduct *) | product |
将一个产品添加到此匹配。
- (GAIDictionaryBuilder *) addProductImpression: | (GAIEcommerceProduct *) | product | |
impressionList: | (NSString *) | name | |
impressionSource: | (NSString *) | source | |
将一次产品展示添加到此匹配。
- (GAIDictionaryBuilder *) addPromotion: | (GAIEcommercePromotion *) | promotion |
将一条促销信息添加到此匹配。