BV Pixel
Introduction
The Bazaarvoice API Analytics solution, better known as BV Pixel, aims to pass events from all views containing user-generated content (UGC) within a client's mobile application to Bazaarvoice. This includes viewing product statistics and UGC display views for Reviews, Questions, and Answers. Using this collected data, Bazaarvoice reports on the influence that UGC has throughout the client's mobile application.
Before you start implementing this Mobile SDK module, verify your installation by checking the steps on the Installation page.
The sections below provide an overview of all the available BV Pixel events, as well as source examples in Swift and Objective-C on how to construct and send them. Please refer to the Requirements page for an overview of which events are required, depending on how you are using the SDK and APIs.
BVTransactionEvent
The Transaction event should execute once the user has completed a purchase. This will often be after a payment has been processed or when loading of a payment confirmation page. The sample code below shows the necessary initializer for creating and sending an eCommerce transactions analytics event.
/*
Construct an array of BVTransactionItem based on the transaction.
Sku is required but the more parameters provided the better.
*/
let firstItem = BVTransactionItem(sku: "123",
name: "cat food",
category: "pets",
price: 10.99,
quantity: 1,
imageUrl: "http://example.com/catfood.jpg")
let secondItem = BVTransactionItem(sku: "321",
name: "dog food",
category: "pets",
price: 14.99,
quantity: 1,
imageUrl: "http://example.com/dogfood.jpg")
let transactionItems = [firstItem, secondItem]
/*
Construct a BVTransactionEvent
OrderId, orderTotal, and orderItems are required.
You may include any other key value params you'd like.
BVTransactionEvent also has convenience setters for commonly used params.
*/
let transaction = BVTransactionEvent(orderId: "order id",
orderTotal: 33.11,
orderItems: transactionItems,
andOtherParams: ["state": "TX", "email": "[email protected]"])
transaction.shipping = 4.99
transaction.tax = 2.14
/*
Use the BVPixel to track the Conversion Transaction Event.
*/
BVPixel.trackEvent(transaction)
/*
Construct an array of BVTransactionItem based on the transaction.
Sku is required but the more parameters provided the better.
*/
BVTransactionItem * firstItem = [
[BVTransactionItem alloc] initWithSku: @ "123"
name: @ "cat food"
category: @ "pets"
price: 10.99
quantity: 1
imageUrl: @ "http://example.com/catfood.jpg"
];
BVTransactionItem * secondItem = [
[BVTransactionItem alloc] initWithSku: @ "321"
name: @ "dog food"
category: @ "pets"
price: 14.99
quantity: 1
imageUrl: @ "http://example.com/dogfood.jpg"
];
NSArray * transactionItems = @[firstItem, secondItem];
/*
Construct a BVTransactionEvent
OrderId, orderTotal, and orderItems are required.
You may include any other key value params you'd like.
BVTransaction also has convenience setters for commonly used params.
*/
BVTransactionEvent * transaction = [
[BVTransactionEvent alloc] initWithOrderId: @ "order id"
orderTotal: 33.11
orderItems: transactionItems
andOtherParams: @ {
@ "state": @ "TX", @ "email": @ "[email protected]"
}
];
transaction.shipping = 4.99;
transaction.tax = 2.14;
/*
Use the BVPixel to track the Conversion Transaction Event.
*/
[BVPixel trackEvent: transaction];
/*
Construct an array of BVAnalyticsTransactionItem based on the transaction.
Sku is required but the more parameters provided the better.
*/
let firstItem = BVAnalyticsTransactionItem(
category: "pets",
imageURL: "http://example.com/catfood.jpg",
name: "cat food",
price: 10.99,
quantity: 1,
sku: "123")
let secondItem = BVAnalyticsTransactionItem(
category: "pets",
imageURL: "http://example.com/dogfood.jpg",
name: "dog food",
price: 14.99,
quantity: 1,
sku: "321")
let transactionItems = [firstItem, secondItem]
/*
Construct a BVAnalyticsEvent.transaction
orderId, total, and items are required.
You may include any other key value params you'd like.
*/
let transaction = BVAnalyticsEvent.transaction(items: transactionItems,
orderId: "order id",
total: 33.11,
city: "Austin",
country: "USA",
currency: "US",
shipping: 4.99,
state: "TX",
tax: 2.14,
additional: [email ":"
some.one @domain.com
])
/*
Use the BVPixel to track the Conversion Transaction Event.
*/
BVPixel.track(transaction)
BVConversionEvent
For non-eCommerce sites, this analytics metric that should be implemented is described below. Known as a non-eCommerce conversion, this analytic event handles user-interaction not convered by other events, such as downloading a brochure, or logging into a service.
/*
Construct a BVConversionEvent
Type and value are required. Label is recommended.
Include any other key value params you want.
*/
let conversion = BVConversionEvent("BrochureDownload",
value: "YourDefinedValue",
label: "Model xyz brochure",
otherParams: ["state": "TX", "email": "[email protected]"])
/*
Use the BVPixel to track the Non-commerce Conversion Event.
*/
BVPixel.trackEvent(conversion)
/*
Construct a BVConversionEvent
Type and value are required. Label is recommended.
Include any other key value params you want.
*/
BVConversionEvent * conversion = [
[BVConversionEvent alloc] initWithType: @ "BrochureDownload"
value: @ "YourDefinedValue"
label: @ "Model xyz brochure"
otherParams: @ {
@ "state": @ "TX", @ "email": @ "[email protected]"
}
];
/*
Use the BVPixel to track the Non-commerce Conversion Event.
*/
[BVPixel trackEvent: conversion];
/*
Construct a BVAnalyticsEvent.conversion event
Type and value are required. Label is recommended.
Include any other key value params you want.
*/
let conversion: BVAnalyticsEvent =
.conversion(
type: "BrochureDownload",
value: "YourDefinedValue",
label: "Model xyz brochure",
additional: ["state": "TX", "email": "[email protected]"])
/*
Use the BVPixel to track the Non-commerce Conversion Event.
*/
BVPixel.track(conversion)
BVPageViewEvent
Execute a PageView event when a product detail page is fully rendered and the page view data is available. A PageView will typically be associated with review and/or question statistics.
/**
Construct this event when products, statistics, or UGC are requested to be displayed on screen.
*/
let pageViewEvent = BVPageViewEvent(productId: "productId",
with: .conversationsReviews,
withBrand: "brandName",
withCategoryId: "optionalCategoryId",
withRootCategoryId: "optionalRootCategoryId",
withAdditionalParams: nil)
BVPixel.trackEvent(pageViewEvent)
/**
Construct this event when products, statistics, or UGC are requested to be displayed on screen.
*/
BVPageViewEvent * pageViewEvent = [
[BVPageViewEvent alloc]
initWithProductId: @ "productId"
withBVPixelProductType: BVPixelProductTypeConversationsReviews
withBrand: @ "brandName"
withCategoryId: @ "optionalCategoryId"
withRootCategoryId: @ "optionalRootCategoryId"
withAdditionalParams: nil
];
[BVPixel trackEvent: pageViewEvent];
let pageView: BVAnalyticsEvent =
.pageView(
bvProduct: .reviews,
productId: "productId",
brand: "brandName",
categoryId: "categoryId",
rootCategoryId: "rootCategoryId",
additional: nil)
BVPixel.track(pageView)
BVInViewEvent
An InView event should be used to indicate that UGC is visible on the view. This event is triggered when user-generated content is made visible on the mobile screen. This should only be fired once per ViewController load. The code below shows you how to track an InView event.
let inViewEvent = BVInViewEvent(productId: "productId",
withBrand: "brandName",
with: .conversationsReviews,
withContainerId: "yourViewControllerName",
withAdditionalParams: nil)
BVPixel.trackEvent(inViewEvent)
BVInViewEvent * inViewEvent = [
[BVInViewEvent alloc] initWithProductId: @ "productId"
withBrand: @ "brandName"
withProductType: BVPixelProductTypeConversationsReviews
withContainerId: @ "nameOfYourViewController"
withAdditionalParams: nil
];
[BVPixel trackEvent: inViewEvent];
let inViewEvent: BVAnalyticsEvent =
.inView(
bvProduct: .reviews,
component: "yourViewControllerName",
productId: "productId",
brand: "brandName",
additional: nil)
BVPixel.track(inViewEvent)
BVImpressionEvent
This event communicates the various pieces of user generated content on a given view back to Bazaarvoice. For each review, question or answer on a UIView, an Impression event must be sent. The code below show you how to implement an Impression Event.
let reviewImpression = BVImpressionEvent(productId: "productId",
withContentId: "optionalContentId",
withCategoryId: "optinalCategoryId",
with: .conversationsReviews,
with: .typeReview, withBrand: "optionalBrand",
withAdditionalParams: nil)
BVPixel.trackEvent(reviewImpression)
BVImpressionEvent * reviewImpression = [
[BVImpressionEvent alloc] initWithProductId: @ "productId"
withContentId: @ "optionalContentId"
withCategoryId: @ "optionalCategoryId"
withProductType: BVPixelProductTypeConversationsReviews
withContentType: BVPixelImpressionContentTypeReview
withBrand: nil withAdditionalParams: nil
];
[BVPixel trackEvent: reviewImpression];
- Swift SDK
-
let reviewImpression: BVAnalyticsEvent = .impression( bvProduct: .reviews, contentId: "optionalContentId", contentType: .review, productId: "productId", brand: "optionalBrand", categoryId: "optinalCategoryId", additional: nil) BVPixel.track(reviewImpression)
BVFeatureUsedEvent
It is not enough to know that a user has viewed a product page. It is valuable to also know how end users interact with user-generated content on a mobile app view. This information can provide insights on the information users value before making a conversion, or purchase.
let writeReviewEvent = BVFeatureUsedEvent(productId: "productId",
withBrand: "optionalBrand",
with: .conversationsReviews,
with: .eventNameWriteReview,
withAdditionalParams: nil)
BVPixel.trackEvent(writeReviewEvent)
BVFeatureUsedEvent * writeReviewEvent = [
[BVFeatureUsedEvent alloc] initWithProductId: @ "productId"
withBrand: @ "brandName"
withProductType: BVPixelProductTypeConversationsReviews
withEventName: BVPixelFeatureUsedEventNameWriteReview
withAdditionalParams: nil
];
[BVPixel trackEvent: writeReviewEvent];
let writeReviewEvent: BVAnalyticsEvent =
.feature(
bvProduct: .reviews,
name: .reviewComment,
productId: "productId",
brand: "optionalBrand",
additional: nil)
BVPixel.track(writeReviewEvent)
BVViewedCGCEvent
This event is triggered when user-generated content is made visible for a set amount of time. Typically this means that UGC was on the mobile screen for greater than 5 seconds, giving an understanding the end-user likely read the content.
let viewedCGCEvent = BVViewedCGCEvent(productId: "productId",
withRootCategoryID: "rootCatId",
withCategoryId: "catId",
with: .conversationsQuestionAnswer,
withBrand: "brandName",
withAdditionalParams: nil)
BVPixel.trackEvent(viewedCGCEvent)
BVViewedCGCEvent * viewedCGCEvent = [
[BVViewedCGCEvent alloc] initWithProductId: @ "productId"
withRootCategoryID: nil
withCategoryId: @ "myCategoryId"
withProductType: BVPixelProductTypeConversationsReviews
withBrand: nil
withAdditionalParams: nil
];
[BVPixel trackEvent: viewedCGCEvent];
let viewed: BVAnalyticsEvent =
.viewed(
bvProduct: .reviews,
productId: "productId",
brand: "brandName",
categoryId: "catId",
rootCategoryId: "rootCatId",
additional: nil)
BVPixel.track(viewed)
Updated 8 months ago