Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for e-commerce tracking #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions src/ios/GAPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,25 @@ - (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)
{

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) {
Expand All @@ -158,21 +163,27 @@ - (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)
{

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) {
Expand Down
13 changes: 11 additions & 2 deletions www/GAPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
};
Expand All @@ -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){
Expand Down