8 |
9 | #import "GAIEcommerceProduct.h"
10 | #import "GAIEcommerceProductAction.h"
11 | #import "GAIEcommercePromotion.h"
12 |
13 | /*!
14 | * Helper class to build a dictionary of hit parameters and values.
15 | *
16 | * Examples:
17 | *
18 | * id t = // get a tracker.
19 | * [t send:[[[GAIDictionaryBuilder createEventWithCategory:@"EventCategory"
20 | * action:@"EventAction"
21 | * label:nil
22 | * value:nil]
23 | * set:@"dimension1" forKey:[GAIFields customDimensionForIndex:1]] build]];
24 | *
25 | * This will send an event hit type with the specified parameters
26 | * and a custom dimension parameter.
27 | *
28 | * If you want to send a parameter with all hits, set it on GAITracker directly.
29 | *
30 | * [t set:kGAIScreenName value:@"Home"];
31 | * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+"
32 | * action:@"PlusOne"
33 | * target:@"SOME_URL"] build]];
34 | * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+"
35 | * action:@"Share"
36 | * target:@"SOME_POST"] build]];
37 | * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+"
38 | * action:@"HangOut"
39 | * target:@"SOME_CIRCLE"]
40 | * build]];
41 | *
42 | * You can override a value set on the tracker by adding it to the dictionary.
43 | *
44 | * [t set:kGAIScreenName value:@"Home"];
45 | * [t send:...];
46 | * [t send[[[GAIDictionaryBuilder createEventWithCategory:@"click"
47 | * action:@"popup"
48 | * label:nil
49 | * value:nil]
50 | * set:@"popup title" forKey:kGAIScreenName] build]];
51 | *
52 | * The values set via [GAIDictionaryBuilder set] or
53 | * [GAIDictionaryBuilder setAll] will override any existing values in the
54 | * GAIDictionaryBuilder object (i.e. initialized by
55 | * [GAIDictionaryBuilder createXYZ]). e.g.
56 | *
57 | * GAIDictionaryBuilder *m =
58 | * GAIDictionaryBuilder createTimingWithCategory:@"category"
59 | * interval:@0
60 | * name:@"name"
61 | * label:nil];
62 | * [t send:[m.set:@"10" forKey:kGAITimingVar] build];
63 | * [t send:[m.set:@"20" forKey:kGAITimingVar] build];
64 | *
65 | */
66 | @interface GAIDictionaryBuilder : NSObject
67 |
68 | - (GAIDictionaryBuilder *)set:(NSString *)value
69 | forKey:(NSString *)key;
70 |
71 | /*!
72 | * Copies all the name-value pairs from params into this object, ignoring any
73 | * keys that are not NSString and any values that are neither NSString or
74 | * NSNull.
75 | */
76 | - (GAIDictionaryBuilder *)setAll:(NSDictionary *)params;
77 |
78 | /*!
79 | * Returns the value for the input parameter paramName, or nil if paramName
80 | * is not present.
81 | */
82 | - (NSString *)get:(NSString *)paramName;
83 |
84 | /*!
85 | * Return an NSMutableDictionary object with all the parameters set in this
86 | */
87 | - (NSMutableDictionary *)build;
88 |
89 | /*!
90 | * Parses and translates utm campaign parameters to analytics campaign param
91 | * and returns them as a map.
92 | *
93 | * @param params url containing utm campaign parameters.
94 | *
95 | * Valid campaign parameters are:
96 | *
97 | * - utm_id
98 | * - utm_campaign
99 | * - utm_content
100 | * - utm_medium
101 | * - utm_source
102 | * - utm_term
103 | * - dclid
104 | * - gclid
105 | * - gmob_t
106 | * - aclid
107 | * - anid
108 | *
109 | *
110 | * Example:
111 | * http://my.site.com/index.html?utm_campaign=wow&utm_source=source
112 | * utm_campaign=wow&utm_source=source.
113 | *
114 | * For more information on manual and auto-tagging, see
115 | * https://support.google.com/analytics/answer/1733663?hl=en
116 | */
117 | - (GAIDictionaryBuilder *)setCampaignParametersFromUrl:(NSString *)urlString;
118 |
119 | /*!
120 | Returns a GAIDictionaryBuilder object with parameters specific to an appview
121 | hit.
122 |
123 | Note that using this method will not set the screen name for followon hits. To
124 | do that you need to call set:kGAIDescription value: on the
125 | GAITracker instance.
126 |
127 | This method is deprecated. Use createScreenView instead.
128 | */
129 | + (GAIDictionaryBuilder *)createAppView DEPRECATED_MSG_ATTRIBUTE("Use createScreenView instead.");
130 |
131 | /*!
132 | Returns a GAIDictionaryBuilder object with parameters specific to a screenview
133 | hit.
134 |
135 | Note that using this method will not set the screen name for followon hits. To
136 | do that you need to call set:kGAIDescription value: on the
137 | GAITracker instance.
138 | */
139 | + (GAIDictionaryBuilder *)createScreenView;
140 |
141 | /*!
142 | Returns a GAIDictionaryBuilder object with parameters specific to an event hit.
143 | */
144 | + (GAIDictionaryBuilder *)createEventWithCategory:(NSString *)category
145 | action:(NSString *)action
146 | label:(NSString *)label
147 | value:(NSNumber *)value;
148 |
149 | /*!
150 | Returns a GAIDictionaryBuilder object with parameters specific to an exception
151 | hit.
152 | */
153 | + (GAIDictionaryBuilder *)createExceptionWithDescription:(NSString *)description
154 | withFatal:(NSNumber *)fatal;
155 |
156 | /*!
157 | Returns a GAIDictionaryBuilder object with parameters specific to an item hit.
158 | */
159 | + (GAIDictionaryBuilder *)createItemWithTransactionId:(NSString *)transactionId
160 | name:(NSString *)name
161 | sku:(NSString *)sku
162 | category:(NSString *)category
163 | price:(NSNumber *)price
164 | quantity:(NSNumber *)quantity
165 | currencyCode:(NSString *)currencyCode;
166 |
167 | /*!
168 | Returns a GAIDictionaryBuilder object with parameters specific to a social hit.
169 | */
170 | + (GAIDictionaryBuilder *)createSocialWithNetwork:(NSString *)network
171 | action:(NSString *)action
172 | target:(NSString *)target;
173 |
174 | /*!
175 | Returns a GAIDictionaryBuilder object with parameters specific to a timing hit.
176 | */
177 | + (GAIDictionaryBuilder *)createTimingWithCategory:(NSString *)category
178 | interval:(NSNumber *)intervalMillis
179 | name:(NSString *)name
180 | label:(NSString *)label;
181 |
182 | /*!
183 | Returns a GAIDictionaryBuilder object with parameters specific to a transaction
184 | hit.
185 | */
186 | + (GAIDictionaryBuilder *)createTransactionWithId:(NSString *)transactionId
187 | affiliation:(NSString *)affiliation
188 | revenue:(NSNumber *)revenue
189 | tax:(NSNumber *)tax
190 | shipping:(NSNumber *)shipping
191 | currencyCode:(NSString *)currencyCode;
192 |
193 | /*!
194 | Set the product action field for this hit.
195 | */
196 | - (GAIDictionaryBuilder *)setProductAction:(GAIEcommerceProductAction *)productAction;
197 |
198 | /*!
199 | Adds a product to this hit.
200 | */
201 | - (GAIDictionaryBuilder *)addProduct:(GAIEcommerceProduct *)product;
202 |
203 | /*!
204 | Add a product impression to this hit.
205 | */
206 | - (GAIDictionaryBuilder *)addProductImpression:(GAIEcommerceProduct *)product
207 | impressionList:(NSString *)name
208 | impressionSource:(NSString *)source;
209 |
210 | /*!
211 | Add a promotion to this hit.
212 | */
213 | - (GAIDictionaryBuilder *)addPromotion:(GAIEcommercePromotion *)promotion;
214 | @end
215 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAIEcommerceFields.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAIEcommerceFields.h
3 | @abstract Google Analytics iOS SDK Ecommerce Hit Format Header
4 | @copyright Copyright 2014 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | This class provides several fields and methods useful as wire format parameters for
11 | Enhanced Ecommerce. See the online developer guides for Enhanced Ecommerce for details
12 | on how to use the Enhanced Ecommerce features.
13 | */
14 |
15 | // Enhanced Ecommerce Product fields
16 | extern NSString *const kGAIProductId;
17 | extern NSString *const kGAIProductName;
18 | extern NSString *const kGAIProductBrand;
19 | extern NSString *const kGAIProductCategory;
20 | extern NSString *const kGAIProductVariant;
21 | extern NSString *const kGAIProductPrice;
22 | extern NSString *const kGAIProductQuantity;
23 | extern NSString *const kGAIProductCouponCode;
24 | extern NSString *const kGAIProductPosition;
25 |
26 | extern NSString *const kGAIProductAction;
27 |
28 | // product action values
29 | extern NSString *const kGAIPADetail;
30 | extern NSString *const kGAIPAClick;
31 | extern NSString *const kGAIPAAdd;
32 | extern NSString *const kGAIPARemove;
33 | extern NSString *const kGAIPACheckout;
34 | extern NSString *const kGAIPACheckoutOption;
35 | extern NSString *const kGAIPAPurchase;
36 | extern NSString *const kGAIPARefund;
37 |
38 | // product action fields
39 | // used for 'purchase' and 'refund' actions
40 | extern NSString *const kGAIPATransactionId;
41 | extern NSString *const kGAIPAAffiliation;
42 | extern NSString *const kGAIPARevenue;
43 | extern NSString *const kGAIPATax;
44 | extern NSString *const kGAIPAShipping;
45 | extern NSString *const kGAIPACouponCode;
46 | // used for 'checkout' action
47 | extern NSString *const kGAICheckoutStep;
48 | extern NSString *const kGAICheckoutOption;
49 | // used for 'detail' and 'click' actions
50 | extern NSString *const kGAIProductActionList;
51 | extern NSString *const kGAIProductListSource;
52 |
53 | // Enhanced Ecommerce Impressions fields
54 | extern NSString *const kGAIImpressionName;
55 | extern NSString *const kGAIImpressionListSource;
56 | extern NSString *const kGAIImpressionProduct;
57 | extern NSString *const kGAIImpressionProductId;
58 | extern NSString *const kGAIImpressionProductName;
59 | extern NSString *const kGAIImpressionProductBrand;
60 | extern NSString *const kGAIImpressionProductCategory;
61 | extern NSString *const kGAIImpressionProductVariant;
62 | extern NSString *const kGAIImpressionProductPosition;
63 | extern NSString *const kGAIImpressionProductPrice;
64 |
65 | // Enhanced Ecommerce Promotions fields
66 | extern NSString *const kGAIPromotionId;
67 | extern NSString *const kGAIPromotionName;
68 | extern NSString *const kGAIPromotionCreative;
69 | extern NSString *const kGAIPromotionPosition;
70 |
71 | // Promotion actions
72 | extern NSString *const kGAIPromotionAction;
73 | extern NSString *const kGAIPromotionView;
74 | extern NSString *const kGAIPromotionClick;
75 |
76 | @interface GAIEcommerceFields : NSObject
77 |
78 | /*!
79 | Generates an enhanced ecommerce product field. Note that field names generated by
80 | customDimensionForIndex and customMetricForIndex can be used as suffixes.
81 |
82 | @param index the index of the product
83 | @param suffix the product field suffix (such as kGAIProductPrice).
84 |
85 | @return an NSString representing the product field parameter
86 | */
87 | + (NSString *)productFieldForIndex:(NSUInteger)index suffix:(NSString *)suffix;
88 |
89 | /*!
90 | Genrates an enhanced ecommerce impression list field name with an index. The return value of
91 | this method should also be used as input to the productImpressionForList method below.
92 |
93 | @param index the index of the impression list
94 |
95 | @return an NSString representing the impression list parameter
96 | */
97 | + (NSString *)impressionListForIndex:(NSUInteger)index;
98 |
99 | /*!
100 | Generates an enhanced ecommerce product impression field with the impression list, product index
101 | and product suffix as parameters. The output of the method impressionListForIndex above should be
102 | used as the input list for this method. The output of customDimensionForIndex and
103 | customMetricForIndex can be used as suffixes.
104 |
105 | @param list the impression list for this product impression
106 | @param index the index of this product in the impression list
107 | @param suffix the product impression suffix for this field
108 |
109 | @return an NSString representing this product impression field parameter
110 | */
111 | + (NSString *)productImpressionForList:(NSString *)list
112 | index:(NSUInteger)index
113 | suffix:(NSString *)Suffix;
114 |
115 | /*!
116 | Generates an enhanced ecommerce promotion field with an index and suffix.
117 |
118 | @param index the index of the promotion
119 | @param suffix the promotion suffix (such as kGAIPromotionId)
120 |
121 | @return an NSString representing this promotion field paramter
122 | */
123 | + (NSString *)promotionForIndex:(NSUInteger)index suffix:(NSString *)suffix;
124 | @end
125 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAIEcommerceProduct.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAIEcommerceProduct.h
3 | @abstract Google Analytics iOS SDK Hit Format Header
4 | @copyright Copyright 2014 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | * Class to construct product related information for a Google Analytics beacon. Use this class to
11 | * report information about products sold by merchants or impressions of products seen by users.
12 | * Instances of this class can be associated with both Product Actions and Product
13 | * Impression Lists.
14 | *
15 | * Typical usage:
16 | *
17 | * [tracker set:kGAIScreenName value:@"MyScreen"];
18 | * GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
19 | * GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init];
20 | * [product setId:@""PID-1234""];
21 | * [product setName:@"Space Monkeys!"];
22 | * [product setPrice:@100];
23 | * [product setQuantity:@2];
24 | * [builder addProductImpression:product impressionList:@"listName"];
25 | * [tracker send:[builder build]];
26 | *
27 | */
28 | @interface GAIEcommerceProduct : NSObject
29 |
30 | /*!
31 | Sets the id that is used to identify a product in GA reports.
32 | */
33 | - (GAIEcommerceProduct *)setId:(NSString *)productId;
34 |
35 | /*!
36 | Sets the name that is used to indentify the product in GA reports.
37 | */
38 | - (GAIEcommerceProduct *)setName:(NSString *)productName;
39 |
40 | /*!
41 | Sets the brand associated with the product in GA reports.
42 | */
43 | - (GAIEcommerceProduct *)setBrand:(NSString *)productBrand;
44 |
45 | /*!
46 | Sets the category associated with the product in GA reports.
47 | */
48 | - (GAIEcommerceProduct *)setCategory:(NSString *)productCategory;
49 |
50 | /*!
51 | Sets the variant of the product.
52 | */
53 | - (GAIEcommerceProduct *)setVariant:(NSString *)productVariant;
54 |
55 | /*!
56 | Sets the price of the product.
57 | */
58 | - (GAIEcommerceProduct *)setPrice:(NSNumber *)productPrice;
59 |
60 | /*!
61 | Sets the quantity of the product. This field is usually not used with product impressions.
62 | */
63 | - (GAIEcommerceProduct *)setQuantity:(NSNumber *)productQuantity;
64 |
65 | /*!
66 | Sets the coupon code associated with the product. This field is usually not used with product
67 | impressions.
68 | */
69 | - (GAIEcommerceProduct *)setCouponCode:(NSString *)productCouponCode;
70 |
71 | /*!
72 | Sets the position of the product on the screen/product impression list, etc.
73 | */
74 | - (GAIEcommerceProduct *)setPosition:(NSNumber *)productPosition;
75 |
76 | /*!
77 | Sets the custom dimension associated with this product.
78 | */
79 | - (GAIEcommerceProduct *)setCustomDimension:(NSUInteger)index value:(NSString *)value;
80 |
81 | /*!
82 | Sets the custom metric associated with this product.
83 | */
84 | - (GAIEcommerceProduct *)setCustomMetric:(NSUInteger)index value:(NSNumber *)value;
85 |
86 | /*!
87 | Builds an NSDictionary of fields stored in this instance suitable for a product action. The
88 | index parameter is the index of this product in the product action list.
89 |
90 | Normally, users will have no need to call this method.
91 | */
92 | - (NSDictionary *)buildWithIndex:(NSUInteger)index;
93 |
94 | /*!
95 | Builds an NSDictionary of fields stored in this instance suitable for an impression list. The
96 | lIndex parameter is the index of the product impression list while the index parameter is the
97 | index of this product in that impression list.
98 |
99 | Normally, users will have no need to call this method.
100 | */
101 | - (NSDictionary *)buildWithListIndex:(NSUInteger)lIndex index:(NSUInteger)index;
102 | @end
103 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAIEcommerceProductAction.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAIProductAction.h
3 | @abstract Google Analytics iOS SDK Hit Format Header
4 | @copyright Copyright 2014 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | * Class to construct transaction/checkout or other product interaction related information for a
11 | * Google Analytics hit. Use this class to report information about products sold, viewed or
12 | * refunded. This class is intended to be used with GAIDictionaryBuilder.
13 | *
14 | * Typical usage:
15 | *
16 | * [tracker set:kGAIScreenName value:@"MyScreen"];
17 | * GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
18 | * GAIEcommerceProductAction *action = [[GAIEcommerceProductAction alloc] init];
19 | * [action setAction:kGAIPAPurchase];
20 | * [action setTransactionId:@"TT-1234"];
21 | * [action setRevenue:@3.14];
22 | * [action setCouponCode:@"EXTRA100"];
23 | * [builder setProductAction:action];
24 | * GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init];
25 | * [product setId:@""PID-1234""];
26 | * [product setName:@"Space Monkeys!"];
27 | * [product setPrice:@100];
28 | * [product setQuantity:@2];
29 | * [builder addProduct:product];
30 | * [tracker send:[builder build]];
31 | *
32 | */
33 | @interface GAIEcommerceProductAction : NSObject
34 |
35 | /*!
36 | Sets the product action field for this product action. Valid values can be found in
37 | GAIEcommerceFields.h under "product action values".
38 | */
39 | - (GAIEcommerceProductAction *)setAction:(NSString *)productAction;
40 |
41 | /*!
42 | The unique id associated with the transaction. This value is used for kGAIPAPurchase and
43 | kGAIPARefund product actions.
44 | */
45 | - (GAIEcommerceProductAction *)setTransactionId:(NSString *)transactionId;
46 |
47 | /*!
48 | Sets the transaction's affiliation value. This value is used for kGAIPAPurchase and
49 | kGAIPARefund product actions.
50 | */
51 | - (GAIEcommerceProductAction *)setAffiliation:(NSString *)affiliation;
52 |
53 | /*!
54 | Sets the transaction's total revenue. This value is used for kGAIPAPurchase and kGAIPARefund
55 | product actions.
56 | */
57 | - (GAIEcommerceProductAction *)setRevenue:(NSNumber *)revenue;
58 |
59 | /*!
60 | Sets the transaction's total tax. This value is used for kGAIPAPurchase and kGAIPARefund
61 | product actions.
62 | */
63 | - (GAIEcommerceProductAction *)setTax:(NSNumber *)tax;
64 |
65 | /*!
66 | Sets the transaction's total shipping costs. This value is used for kGAIPAPurchase and
67 | kGAIPARefund product actions.
68 | */
69 | - (GAIEcommerceProductAction *)setShipping:(NSNumber *)shipping;
70 |
71 | /*!
72 | Sets the coupon code used in this transaction. This value is used for kGAIPAPurchase and
73 | kGAIPARefund product actions.
74 | */
75 | - (GAIEcommerceProductAction *)setCouponCode:(NSString *)couponCode;
76 |
77 | /*!
78 | Sets the checkout process's progress. This value is used for kGAICheckout and
79 | kGAICheckoutOptions product actions.
80 | */
81 | - (GAIEcommerceProductAction *)setCheckoutStep:(NSNumber *)checkoutStep;
82 |
83 | /*!
84 | Sets the option associated with the checkout. This value is used for kGAICheckout and
85 | kGAICheckoutOptions product actions.
86 | */
87 | - (GAIEcommerceProductAction *)setCheckoutOption:(NSString *)checkoutOption;
88 |
89 | /*!
90 | Sets the list name associated with the products in Google Analytics beacons. This value is
91 | used in kGAIPADetail and kGAIPAClick product actions.
92 | */
93 | - (GAIEcommerceProductAction *)setProductActionList:(NSString *)productActionList;
94 |
95 | /*!
96 | Sets the list source name associated with the products in Google Analytics beacons. This value
97 | is used in kGAIPADetail and kGAIPAClick product actions.
98 | */
99 | - (GAIEcommerceProductAction *)setProductListSource:(NSString *)productListSource;
100 |
101 | /*!
102 | Builds an NSDictionary of fields stored in this instance representing this product action.
103 |
104 | Normally, users will have no need to call this method.
105 | */
106 | - (NSDictionary *)build;
107 | @end
108 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAIEcommercePromotion.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAIEcommercePromotion.h
3 | @abstract Google Analytics iOS SDK Hit Format Header
4 | @copyright Copyright 2014 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | * Class to construct promotion related fields for Google Analytics hits. The fields from this class
11 | * can be used to represent internal promotions that run within an app, such as banners, banner ads
12 | * etc.
13 | *
14 | * Typical usage:
15 | *
16 | * GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
17 | * GAIEcommercePromotion *promotion = [[GAIEcommercePromotion alloc] init];
18 | * [promotion setId:@"PROMO-ID1234"];
19 | * [promotion setName:@"Home screen banner"];
20 | * [builder set:kGAIPromotionClick forKey:kGAIPromotionAction];
21 | * [builder addPromotion:promotion];
22 | * [tracker send:builder.build]];
23 | *
24 | */
25 | @interface GAIEcommercePromotion : NSObject
26 |
27 | /*!
28 | Sets the id that is used to identify a promotion in GA reports.
29 | */
30 | - (GAIEcommercePromotion *)setId:(NSString *)pid;
31 |
32 | /*!
33 | Sets the name that is used to identify a promotion in GA reports.
34 | */
35 | - (GAIEcommercePromotion *)setName:(NSString *)name;
36 |
37 | /*!
38 | Sets the name of the creative associated with the promotion.
39 | */
40 | - (GAIEcommercePromotion *)setCreative:(NSString *)creative;
41 |
42 | /*!
43 | Sets the position of the promotion.
44 | */
45 | - (GAIEcommercePromotion *)setPosition:(NSString *)position;
46 |
47 | /*!
48 | Builds an NSDictionary of fields stored in this instance. The index parameter is the
49 | index of this promotion in that promotion list.
50 |
51 | Normally, users will have no need to call this method.
52 | */
53 | - (NSDictionary *)buildWithIndex:(NSUInteger)index;
54 | @end
55 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAIFields.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAIFields.h
3 | @abstract Google Analytics iOS SDK Hit Format Header
4 | @copyright Copyright 2013 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | These fields can be used for the wire format parameter names required by
11 | the |GAITracker| get, set and send methods as well as the set methods in the
12 | |GAIDictionaryBuilder| class.
13 | */
14 | extern NSString *const kGAIUseSecure;
15 |
16 | extern NSString *const kGAIHitType;
17 | extern NSString *const kGAITrackingId;
18 | extern NSString *const kGAIClientId;
19 | extern NSString *const kGAIDataSource;
20 | extern NSString *const kGAIAnonymizeIp;
21 | extern NSString *const kGAISessionControl;
22 | extern NSString *const kGAIDeviceModelVersion;
23 | extern NSString *const kGAIScreenResolution;
24 | extern NSString *const kGAIViewportSize;
25 | extern NSString *const kGAIEncoding;
26 | extern NSString *const kGAIScreenColors;
27 | extern NSString *const kGAILanguage;
28 | extern NSString *const kGAIJavaEnabled;
29 | extern NSString *const kGAIFlashVersion;
30 | extern NSString *const kGAINonInteraction;
31 | extern NSString *const kGAIReferrer;
32 | extern NSString *const kGAILocation;
33 | extern NSString *const kGAIHostname;
34 | extern NSString *const kGAIPage;
35 | extern NSString *const kGAIDescription; // synonym for kGAIScreenName
36 | extern NSString *const kGAIScreenName; // synonym for kGAIDescription
37 | extern NSString *const kGAITitle;
38 | extern NSString *const kGAIAdMobHitId;
39 | extern NSString *const kGAIAppName;
40 | extern NSString *const kGAIAppVersion;
41 | extern NSString *const kGAIAppId;
42 | extern NSString *const kGAIAppInstallerId;
43 | extern NSString *const kGAIUserId;
44 |
45 | extern NSString *const kGAIEventCategory;
46 | extern NSString *const kGAIEventAction;
47 | extern NSString *const kGAIEventLabel;
48 | extern NSString *const kGAIEventValue;
49 |
50 | extern NSString *const kGAISocialNetwork;
51 | extern NSString *const kGAISocialAction;
52 | extern NSString *const kGAISocialTarget;
53 |
54 | extern NSString *const kGAITransactionId;
55 | extern NSString *const kGAITransactionAffiliation;
56 | extern NSString *const kGAITransactionRevenue;
57 | extern NSString *const kGAITransactionShipping;
58 | extern NSString *const kGAITransactionTax;
59 | extern NSString *const kGAICurrencyCode;
60 |
61 | extern NSString *const kGAIItemPrice;
62 | extern NSString *const kGAIItemQuantity;
63 | extern NSString *const kGAIItemSku;
64 | extern NSString *const kGAIItemName;
65 | extern NSString *const kGAIItemCategory;
66 |
67 | extern NSString *const kGAICampaignSource;
68 | extern NSString *const kGAICampaignMedium;
69 | extern NSString *const kGAICampaignName;
70 | extern NSString *const kGAICampaignKeyword;
71 | extern NSString *const kGAICampaignContent;
72 | extern NSString *const kGAICampaignId;
73 | extern NSString *const kGAICampaignAdNetworkClickId;
74 | extern NSString *const kGAICampaignAdNetworkId;
75 |
76 | extern NSString *const kGAITimingCategory;
77 | extern NSString *const kGAITimingVar;
78 | extern NSString *const kGAITimingValue;
79 | extern NSString *const kGAITimingLabel;
80 |
81 | extern NSString *const kGAIExDescription;
82 | extern NSString *const kGAIExFatal;
83 |
84 | extern NSString *const kGAISampleRate;
85 |
86 | extern NSString *const kGAIIdfa;
87 | extern NSString *const kGAIAdTargetingEnabled;
88 |
89 | // hit types
90 | extern NSString *const kGAIAppView DEPRECATED_MSG_ATTRIBUTE("Use kGAIScreenView instead.");
91 | extern NSString *const kGAIScreenView;
92 | extern NSString *const kGAIEvent;
93 | extern NSString *const kGAISocial;
94 | extern NSString *const kGAITransaction;
95 | extern NSString *const kGAIItem;
96 | extern NSString *const kGAIException;
97 | extern NSString *const kGAITiming;
98 |
99 | /*!
100 | This class provides several fields and methods useful as wire format parameter
101 | names. The methods are used for wire format parameter names that are indexed.
102 | */
103 |
104 | @interface GAIFields : NSObject
105 |
106 | /*!
107 | Generates the correct parameter name for a content group with an index.
108 |
109 | @param index the index of the content group.
110 |
111 | @return an NSString representing the content group parameter for the index.
112 | */
113 | + (NSString *)contentGroupForIndex:(NSUInteger)index;
114 |
115 | /*!
116 | Generates the correct parameter name for a custon dimension with an index.
117 |
118 | @param index the index of the custom dimension.
119 |
120 | @return an NSString representing the custom dimension parameter for the index.
121 | */
122 | + (NSString *)customDimensionForIndex:(NSUInteger)index;
123 |
124 | /*!
125 | Generates the correct parameter name for a custom metric with an index.
126 |
127 | @param index the index of the custom metric.
128 |
129 | @return an NSString representing the custom metric parameter for the index.
130 | */
131 | + (NSString *)customMetricForIndex:(NSUInteger)index;
132 |
133 | @end
134 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAILogger.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAILogger.h
3 | @abstract Google Analytics iOS SDK Source
4 | @copyright Copyright 2011 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | typedef NS_ENUM(NSUInteger, GAILogLevel) {
10 | kGAILogLevelNone = 0,
11 | kGAILogLevelError = 1,
12 | kGAILogLevelWarning = 2,
13 | kGAILogLevelInfo = 3,
14 | kGAILogLevelVerbose = 4
15 | };
16 |
17 | /*!
18 | Protocol to be used for logging debug and informational messages from the SDK.
19 | Implementations of this protocol can be provided to the |GAI| class,
20 | to be used as the logger by the SDK. See the |logger| property in GAI.h.
21 | */
22 | @protocol GAILogger
23 | @required
24 |
25 | /*!
26 | Only messages of |logLevel| and below are logged.
27 | */
28 | @property (nonatomic, assign) GAILogLevel logLevel;
29 |
30 | /*!
31 | Logs message with log level |kGAILogLevelVerbose|.
32 | */
33 | - (void)verbose:(NSString *)message;
34 |
35 | /*!
36 | Logs message with log level |kGAILogLevelInfo|.
37 | */
38 | - (void)info:(NSString *)message;
39 |
40 | /*!
41 | Logs message with log level |kGAILogLevelWarning|.
42 | */
43 | - (void)warning:(NSString *)message;
44 |
45 | /*!
46 | Logs message with log level |kGAILogLevelError|.
47 | */
48 | - (void)error:(NSString *)message;
49 | @end
50 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAITrackedViewController.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAITrackedViewController.h
3 | @abstract Google Analytics for iOS Tracked View Controller Header
4 | @copyright Copyright 2012 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 | #import
9 |
10 | @protocol GAITracker;
11 |
12 | /*!
13 | Extends UIViewController to generate Google Analytics screenview calls
14 | whenever the view appears; this is done by overriding the `viewDidAppear:`
15 | method. The screen name must be set for any tracking calls to be made.
16 |
17 | By default, this will use [GAI defaultTracker] for tracking calls, but one can
18 | override this by setting the tracker property.
19 | */
20 | @interface GAITrackedViewController : UIViewController
21 |
22 | /*!
23 | The tracker on which view tracking calls are be made, or `nil`, in which case
24 | [GAI defaultTracker] will be used.
25 | */
26 | @property(nonatomic, assign) id tracker;
27 | /*!
28 | The screen name, for purposes of Google Analytics tracking. If this is `nil`,
29 | no tracking calls will be made.
30 | */
31 | @property(nonatomic, copy) NSString *screenName;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/project/iPhone/include/GAITracker.h:
--------------------------------------------------------------------------------
1 | /*!
2 | @header GAITracker.h
3 | @abstract Google Analytics iOS SDK Tracker Header
4 | @copyright Copyright 2013 Google Inc. All rights reserved.
5 | */
6 |
7 | #import
8 |
9 | /*!
10 | Google Analytics tracking interface. Obtain instances of this interface from
11 | [GAI trackerWithTrackingId:] to track screens, events, transactions, timing,
12 | and exceptions. The implementation of this interface is thread-safe, and no
13 | calls are expected to block or take a long time. All network and disk activity
14 | will take place in the background.
15 | */
16 | @protocol GAITracker
17 |
18 | /*!
19 | Name of this tracker.
20 | */
21 | @property(nonatomic, readonly) NSString *name;
22 |
23 | /*!
24 | Allow collection of IDFA and related fields if set to true. Default is false.
25 | */
26 | @property(nonatomic) BOOL allowIDFACollection;
27 |
28 | /*!
29 | Set a tracking parameter.
30 |
31 | @param parameterName The parameter name.
32 |
33 | @param value The value to set for the parameter. If this is nil, the
34 | value for the parameter will be cleared.
35 | */
36 | - (void)set:(NSString *)parameterName
37 | value:(NSString *)value;
38 |
39 | /*!
40 | Get a tracking parameter.
41 |
42 | @param parameterName The parameter name.
43 |
44 | @returns The parameter value, or nil if no value for the given parameter is
45 | set.
46 | */
47 | - (NSString *)get:(NSString *)parameterName;
48 |
49 | /*!
50 | Queue tracking information with the given parameter values.
51 |
52 | @param parameters A map from parameter names to parameter values which will be
53 | set just for this piece of tracking information, or nil for none.
54 | */
55 | - (void)send:(NSDictionary *)parameters;
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/project/include/Utils.h:
--------------------------------------------------------------------------------
1 | #ifndef GA_H
2 | #define GA_H
3 |
4 |
5 | namespace ganalytics {
6 |
7 |
8 | void startNewSession( const char *sUID , int iPeriod );
9 | void sendScreenView( const char *sScreen );
10 | void setUserId( const char *sUserId );
11 | void sendEvent( const char *sCat , const char *sAction,const char *sLabel , int iValue );
12 | void sendSocial( const char *sSocial_network , const char *sAction , const char *sTarget );
13 | void setCustom_dimension( int iIndex , const char *sValue );
14 | void setCustom_metric( int iIndex , int iMetric );
15 | void sendTiming( const char *sCat , int iInterval , const char *sName , const char *sLabel );
16 | void stopSession( );
17 | void sendUncaughtException( const char *description, bool fatal );
18 |
19 | }
20 |
21 |
22 | #endif
--------------------------------------------------------------------------------