Skip to main content

Usage

Each time a view (Activity or Fragment) is displayed, the SDK must be notified. You can inform it with an Activity or a View (in the case of an acitvity with several Fragment).

note

Be careful to call the BEYABLE instance after the display view (so that the SDK can consider the display), for example in the case of a Fragment.

Example 'Activity' - Page 'Home'

Notify SDK on a Home Page
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
BYHomeAttributes attributes = new BYHomeAttributes();
Beyable.getSharedInstance().sendPageView(this, "/", attributes);
}

Example 'Fragment' - Page 'Product'

Notify SDK on a Product Page
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
...
// CALL Beyable SDK to inform that we are viewing a product page
BYProductAttributes attributes = new BYProductAttributes();
attributes.setReference(product.getId());
attributes.setName(product.getTitle());
attributes.setStock(product.getStock());
attributes.setSellingPrice(product.getPrice());
attributes.setThumbnailUrl(product.getThumbnail());
attributes.setPriceBeforeDiscount(product.getDiscountPercentage());
attributes.setTags(new String[]{
product.getCategory(),
product.getBrand()
});
Beyable.getSharedInstance().sendPageView(getView(), "product/"+product.getTitle(), attributes);
}

Example - Page 'Category' with a collection of items

Notify SDK on a Category Page
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...

// Send a "page view" of type category to indicate that this page is a 'collection' page
BYCategoryAttributes attributes = new BYCategoryAttributes();
Beyable.getSharedInstance().sendPageView(this, "/", attributes);
}

On the RecyclerView adapter, when the collection item is about to be displayed it is important to be after the display configuration.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
...

Beyable.getSharedInstance().sendViewHolderBinded(holder, context);
}