I am doing the google analytics e-commerce tracking. And when I do any product shipping or any transaction.That value is not updating in my google analytics console.
Here my code :
static func sendGAEvent(_ categoty: String, params: [String : NSObject]){
let tracker = GAI.sharedInstance().tracker(withTrackingId: UA 234234-4)
if let tracker = tracker {
for (k, _) in params{
let key = k
let value = params[k]
if let val = value as? String {
tracker.set(key, value: val)
}
}
if let screenTitle = params[“screen_title” as? String{
tracker.set(kGAIScreenName, value: screenTitle)
guard let builder = GAIDictionaryBuilder.createEvent(withCategory: categoty, action: screenTitle, label: screenTitle, value: 0)
else
{
return
}
tracker.send(builder.build() as [NSObject:AnyObject])
}
if categoty == “shoping_cart”{
let Tid = params[mob_no] as? String
let TRevenue = params[amount] as? String // it will be amount of product getting from params
let TCurrencyCode = params[code] as? String // it will be code of product from params
tracker.set(kGAITransactionId, value: Tid)
tracker.set(kGAITransactionRevenue, value: TRevenue)
tracker.set(kGAICurrencyCode, value: TCurrencyCode)
guard let maker = GAIDictionaryBuilder.createTransaction(withId: Tid, affiliation: optional, revenue: 80, tax: 0, shipping: 0, currencyCode: TCurrencyCode)
else
{
return
}
print("done updating first")
tracker.send(maker.build() as [NSObject:AnyObject])
print("done updating second")
}
}
}
If any expert in google analytics please, give me some solution..!!
Thanks !