Testing Notes & Known Quirks
bp.js Runtime Validation Quirks
Section titled “bp.js Runtime Validation Quirks”Barion’s bp.js script performs client-side validation on event data. In some cases, the validation rules differ from the Barion API reference documentation. These quirks were discovered during staging testing.
totalItemPrice: rejected for contentView, required for contents items
Section titled “totalItemPrice: rejected for contentView, required for contents items”- contentView (flat event): bp.js rejects
totalItemPricewith the errorInvalid key totalItemPrice in contentView event, even though the API reference lists it as a required field. - initiateCheckout and purchase
contentsitems: bp.js requirestotalItemPricewith the errorMandatory key totalItemPrice is missing from contents eventif omitted.
Rule of thumb: totalItemPrice is invalid for flat events but required inside contents array items.
unit is required in contents items
Section titled “unit is required in contents items”bp.js requires unit in the contents array items for initiateCheckout and purchase. Omitting it produces: Mandatory key unit is missing from contents event.
step is required for checkout events
Section titled “step is required for checkout events”The step field is mandatory for addToCart, initiateCheckout, and purchase. The Barion documentation recommends using 1 for single-step checkouts.
Debug Mode
Section titled “Debug Mode”Enable debug mode in Settings > Barion Pixel to log all Barion Pixel events to the browser console.
What to look for
Section titled “What to look for”Open the browser console (F12 > Console) and look for [Barion Pixel] prefixed messages:
[Barion Pixel] bp.js loaded by Advanced Pixel for Barion[Barion Pixel] Base pixel initialized with ID: BP-xxxxxxxxxxxx-xx[Barion Pixel] Consent auto-granted via WP Consent API[Barion Pixel] Event: contentView { contentType: "Product", ... }[Barion Pixel] Event: addToCart { contentType: "Product", ... }[Barion Pixel] Event: initiateCheckout { contents: [...], ... }[Barion Pixel] Event: purchase { contents: [...], ... }[Barion Pixel] setEncryptedEmail sentbp.js errors
Section titled “bp.js errors”bp.js logs its own validation errors with a numeric prefix. Common ones:
| Error | Meaning | Fix |
|---|---|---|
Mandatory key X is missing from Y event |
A required field is not being sent | Check the event data |
Invalid key X in Y event |
A field is being sent that bp.js doesn’t expect | Remove the field |
Testing Checklist
Section titled “Testing Checklist”Product page (contentView)
Section titled “Product page (contentView)”- Navigate to any single product page
- Open browser console
- Verify
[Barion Pixel] Event: contentViewappears - Verify no bp.js error messages about missing/invalid keys
- Check that fields include:
contentType,currency,id,name,quantity,unit,unitPrice
Add to cart (addToCart)
Section titled “Add to cart (addToCart)”From shop/archive page (AJAX):
- Navigate to the shop page
- Open browser console
- Click “Add to cart” on any product
- Verify
[Barion Pixel] Event: addToCartappears - Check fields include
totalItemPriceandstep: 1
From single product page (form submit):
- Navigate to a single product page
- Open browser console
- Click “Add to cart”
- Verify
[Barion Pixel] Event: addToCartfires before the page navigates - For variable products: select a variation first and verify the variation’s price is used
Checkout page (initiateCheckout)
Section titled “Checkout page (initiateCheckout)”- Add items to cart and navigate to checkout
- Open browser console
- Verify
[Barion Pixel] Event: initiateCheckoutappears - Check that
contentsarray has correct items withunit,unitPrice,totalItemPrice - Check that
revenueis subtotal + tax (not including shipping) - Check
step: 1is present
Order completion (purchase + setEncryptedEmail)
Section titled “Order completion (purchase + setEncryptedEmail)”- Complete a test order (use “Bank transfer” payment method for easy testing)
- On the thank-you page, open browser console
- Verify
[Barion Pixel] Event: purchaseappears withrevenuematching the order total - Verify
[Barion Pixel] setEncryptedEmail sentappears - Refresh the thank-you page — verify
purchasedoes NOT fire again (duplicate prevention) - Check that
contentsitems includeunit,totalItemPrice
Consent integration
Section titled “Consent integration”- Clear all cookies
- Navigate to any page
- Verify
[Barion Pixel] Base pixel initializedappears (base pixel always loads) - Accept cookies via your cookie banner
- Verify
[Barion Pixel] Consent grantedappears - Reload the page — verify consent is auto-granted on load (returning visitor)
Common Issues
Section titled “Common Issues”Events not firing
Section titled “Events not firing”- Check Pixel ID: Ensure a valid Pixel ID is configured in Settings > Barion Pixel
- Check full tracking: Events require “Enable Full Pixel Tracking” to be checked
- Check WooCommerce: Full tracking requires WooCommerce to be active
- Check console errors: Look for JavaScript errors that might prevent bp.js from loading
Double pixel loading
Section titled “Double pixel loading”If you see [Barion Pixel] bp.js already loaded by another plugin, another plugin (likely the Barion Payment Gateway) has already loaded bp.js. This is harmless — the plugin skips re-loading and still initializes with your Pixel ID.
Consent not granting
Section titled “Consent not granting”- WP Consent API: Ensure the WP Consent API plugin is installed and your cookie plugin supports it
- Cookie Law Info: Ensure the plugin is active and the
CLIglobal is available - Manual: Call
window.wcBarionGrantConsent()from your consent manager’s callback