'For tracking product impressions which Google Analytics hit type should I use?
Currently for tracking product impressions, I am using below code:
let tracker = GAI.sharedInstance().defaultTracker
let builder = GAIDictionaryBuilder.createScreenView()
let product = getProduct()
let trackProduct = GAIEcommerceProduct()
let impressionList = "test_prod"
trackProduct.setId(product.ID)
trackProduct.setName(product.name)
trackProduct.setCategory(product.category)
trackProduct.setBrand(product.brand)
builder.addProductImpression(trackProduct, impressionList: impressionList, impressionSource: "")
}
if let screenName = screenName {
tracker.set(kGAIScreenName, value: screenName)
}
tracker.add(customDimension: customDimensions)
tracker.send(builder.build() as [NSObject: AnyObject])
My problem is that every time screen view is being tracked. I am getting duplicate screen view's. I want to know how can I create GAIDictionaryBuilder other tha createScreenView. I know there are few other ways likecreateEvent(withCategory: "ca", action: "search", label: nil, value: nil)
But is there a defined way which one to create for tracking impressions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|