BV Pixel
This documentation explains how to use the Bazaarvoice Pixel to capture product purchases as well as non-transactional events, such as 'Store Locator' or 'Where To Buy' clicks.
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.
Installation
With Gradle
Include the Maven Central repository and add the appropriate Bazaarvoice Mobile SDK modules to your dependencies:
dependencies {
implementation 'com.bazaarvoice.bvandroidsdk:analytics:{BV_SDK_VERSION}.+'
}
Replace the {tokens}
, including brackets, with the appropriate values. Refer to the Installation guide for {BV_SDK_VERSION}
.
Extending the application
Create a class that extends android.app.Application
, and initialize the Mobile SDK using its builder.
You can find a full list of build options in BVSDK.java
.
public class MyApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
BVPixel.builder(context, {YOUR_CLIENT_ID}, isStaging)
.bgHandlerThread(optionalBackgroundHandlerThread)
.okHttpClient(optionalOkHttpClient)
.build();
}
}
Replace the {tokens}
with the appropriate values. Ex: {token}
becomes value
. If you are unsure about the correct value, contact Bazaarvoice Support or your implementation team.
App manifest file
Add the following to your AndroidManifest.xml
file.
<!-- set the name of the class for the application entry -->
<application
android:name=".MyApplication">
</application>
Generating events
Event map generation steps
The following code sample demonstrates how to dispatch an analytics events:
// Step 1
// Setup BVPixel
BVPixel.builder(context, "clientId", false)
.okHttpClient(optionalCustomOkHttpClient)
.bgHandlerThread(optionalCustomBgHandlerThread)
.build();
// Step 2
// Create Event
BVPageViewEvent event = new BVPageViewEvent(
"productId",
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
"category"
);
// Step 3
// Send event
BVPixel.getInstance().track(event);
Event map generation examples
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.
BVTransactionItem item1 = new BVTransactionItem.Builder("productId1")
.setName("productName1")
.setQuantity(2)
.setPrice(20.02)
.build();
BVTransactionItem item2 = new BVTransactionItem.Builder("productId2")
.setName("productName2")
.setQuantity(2)
.setPrice(80.02)
.build();
BVTransaction transaction = new BVTransaction.Builder()
.setCity("Austin")
.setState("TX")
.setCountry("USA")
.setTotal(200.08)
.setItems(Arrays.asList(item1, item2))
.build();
BVTransactionEvent event = new BVTransactionEvent(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 converted by other events, such as downloading a brochure, or logging into a service.
BVConversionEvent event = new BVConversionEvent("customType", "customValue", "customLabel");
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.
BVPageViewEvent event = new BVPageViewEvent(
"productId,
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
"categoryId"
);
BVInViewEvent
An InView event should be used to indicate that UGC is visible on the view. This event is triggered when consumer-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.
BVInViewEvent event = new BVInViewEvent(
"productId",
"viewContainerId",
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
"brandName"
);
BVImpressionEvent
This event communicates the various pieces of consumer 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.
BVImpressionEvent event = new BVImpressionEvent(
"productId",
"contentId",
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
BVEventValues.BVImpressionContentType.REVIEW,
"categoryId",
"brandName"
);
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 consumer-generated content on a mobile app view. This information can provide insights on the information users value before making a conversion, or purchase.
BVFeatureUsedEvent event = new BVFeatureUsedEvent(
"productId",
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
BVEventValues.BVFeatureUsedEventType.WRITE_REVIEW,
"brandName"
);
BVViewedCGCEvent
This event is triggered when consumer-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.
BVViewedCgcEvent event = new BVViewedCgcEvent(
"productId",
BVEventValues.BVProductType.CONVERSATIONS_REVIEWS,
"rootCategoryId",
"categoryId",
"brand"
);
Multi client analytics
There is an additional API for sending an event with a different clientId if necessary,
bvPixel.trackEventForClient(event, otherClientId);
Updated about 2 months ago