diff --git a/src/ios/GAPlugin.m b/src/ios/GAPlugin.m index 395b6f7..094fe2e 100644 --- a/src/ios/GAPlugin.m +++ b/src/ios/GAPlugin.m @@ -132,12 +132,12 @@ - (void) trackEcommerceTransaction:(CDVInvokedUrlCommand*) command{ NSString *callbackId = command.callbackId; - NSString *transactionId; - NSString *affiliation; - NSNumber *revenue; - NSNumber *tax; - NSNumber *shipping; - NSString *currencyCode; + NSString *transactionId = [command.arguments objectAtIndex:0]; + NSString *affiliation = [command.arguments objectAtIndex:1]; + NSNumber *revenue = [command.arguments objectAtIndex:2]; + NSNumber *tax = [command.arguments objectAtIndex:3]; + NSNumber *shipping = [command.arguments objectAtIndex:4]; + NSString *currencyCode = [command.arguments objectAtIndex:5]; if(inited) { @@ -145,7 +145,12 @@ - (void) trackEcommerceTransaction:(CDVInvokedUrlCommand*) command{ NSError *error=nil; id tracker=[[GAI sharedInstance] defaultTracker]; @try { - [tracker send:[[GAIDictionaryBuilder createTransactionWithId:(NSString *)transactionId affiliation:(NSString *)affiliation revenue:(NSNumber *)revenue tax:(NSNumber *)tax shipping:(NSNumber *)shipping currencyCode:(NSString *)currencyCode] build]]; + [tracker send:[[GAIDictionaryBuilder createTransactionWithId:(NSString *)transactionId + affiliation:(NSString *)affiliation + revenue:(NSNumber *)revenue + tax:(NSNumber *)tax + shipping:(NSNumber *)shipping + currencyCode:(NSString *)currencyCode] build]]; [self successWithMessage: [NSString stringWithFormat:@"trackEcommerceTransaction: transactionId=%@, affiliation=%@, revenue=%@, tax=%@, shipping=%@, currencyCode=%@", transactionId, affiliation, revenue, tax, shipping, currencyCode] toID:callbackId]; } @catch (NSException *exception) { @@ -158,13 +163,13 @@ - (void) trackEcommerceTransaction:(CDVInvokedUrlCommand*) command{ - (void) trackEcommerceItem:(CDVInvokedUrlCommand*) command{ NSString *callbackId = command.callbackId; - NSString *transactionId; - NSString *name; - NSString *sku; - NSString *category; - NSNumber *price; - NSNumber *quantity; - NSString *currencyCode; + NSString *transactionId = [command.arguments objectAtIndex:0]; + NSString *name = [command.arguments objectAtIndex:1]; + NSString *sku = [command.arguments objectAtIndex:2]; + NSString *category = [command.arguments objectAtIndex:3]; + NSNumber *price = [command.arguments objectAtIndex:4]; + NSNumber *quantity = [command.arguments objectAtIndex:5]; + NSString *currencyCode = [command.arguments objectAtIndex:6]; if(inited) { @@ -172,7 +177,13 @@ - (void) trackEcommerceItem:(CDVInvokedUrlCommand*) command{ NSError *error=nil; id tracker=[[GAI sharedInstance] defaultTracker]; @try { - [tracker send:[[GAIDictionaryBuilder createItemWithTransactionId:transactionId name:name sku:sku category:category price:price quantity:quantity currencyCode:currencyCode] build]]; + [tracker send:[[GAIDictionaryBuilder createItemWithTransactionId:transactionId + name:name + sku:sku + category:category + price:price + quantity:quantity + currencyCode:currencyCode] build]]; [self successWithMessage: [NSString stringWithFormat:@"trackEcommerceItem: transactionId=%@, name=%@, sku=%@, category=%@, price=%@, quantity=%@, currencyCode=%@", transactionId, name, sku, category, price, quantity, currencyCode] toID:callbackId]; } @catch (NSException *exception) { diff --git a/www/GAPlugin.js b/www/GAPlugin.js index 90e6455..79af5c4 100644 --- a/www/GAPlugin.js +++ b/www/GAPlugin.js @@ -40,6 +40,15 @@ return cordovaRef.exec(success, fail, 'GAPlugin', 'setVariable', [index, value]); }; + GAPlugin.prototype.setMetric = function(success, fail, index, value) { + return cordovaRef.exec(success, fail, 'GAPlugin', 'setVariable', [index, value]); + }; + + GAPlugin.prototype.setDimension = function(success, fail, index, value) { + return cordovaRef.exec(success, fail, 'GAPlugin', 'setVariable', [index, value]); + }; + + GAPlugin.prototype.exit = function(success, fail) { return cordovaRef.exec(success, fail, 'GAPlugin', 'exitGA', []); }; @@ -48,8 +57,8 @@ return cordovaRef.exec(success, fail, 'GAPlugin', 'trackSocial', [network, action, target]); }; - GAPlugin.prototype.trackEcommerceTransaction =function(success, fail, affiliation, revenue, tax, shipping, currencyCode){ - return cordovaRef.exec(success, fail, 'GAPlugin', 'trackEcommerceTransaction', [affiliation, revenue, tax, shipping, currencyCode]); + GAPlugin.prototype.trackEcommerceTransaction =function(success, fail, transactionID, affiliation, revenue, tax, shipping, currencyCode){ + return cordovaRef.exec(success, fail, 'GAPlugin', 'trackEcommerceTransaction', [transactionID, affiliation, revenue, tax, shipping, currencyCode]); }; GAPlugin.prototype.trackEcommerceItem =function(success, fail, transactionID, productName, productSKU, productCategory, productPrice, productQuantity,currencyCode){