Inventory Extension¶
The inventory
extension enables events that track products viewed on your
site. You can also ask it directly to fetch/lookup specific products.
Installation¶
This extension can be enabled through Orbee's Platform. If you are manually controlling installation and setup, you can also fetch the plugin here:
<script async src="https://scripts.orb.ee/js-sdk/latest/inventory.js" />
This standalone installation sets up the extension's class on the window object,
under window.OaInventoryExtension
. You can then extend your scope like this:
oa.getScope(YOUR_SCOPE).extend('inventory', OaInventoryExtension);
Configuration¶
This extension requires the following parameters:
account_id
¶
This should be the account token (UUID) for your account.
no default value
cache_size
¶
This should be the size of the inventory's local cache of products. This should be kept relatively small to reserve space on the browser.
This configured cache-size is specific to storing commonly shared vehicles across pages, like going from an inventory page to a product page, that would share the same product on both pages.
Any product fetched by this product is stored in memory while the pageview is active; so we never fetch a product more than once per pageview.
default: 10
inventory_path_pattern
¶
This can be a string regex to detect the path for which you display search results for inventory on your site.
default: '/all-vehicles'
product_path_pattern
¶
This can be a string regex to detect the path for which you display product details on your site.
default: '/inventory/(\w+-)*(\w{17})'
product_ids_pattern
¶
This can be a string regex to detect product IDs on your web pages.
default: '[vV][Ii][Nn]:?\s*(\w{17})'
Methods¶
This extension has a variety of available attributes and functions to call.
inventory.fetcher
¶
This is an object you can use to fetch product details from Orbee's Marketing Cloud.
inventory.getProductDetails(lookup, cb)
¶
This function requests the details of the product with the given lookup. You can optionally provide a callback once the SDK has retrieved the data
inventory.viewManager.pageType
¶
This is one of the following: 'inventory'
(search page), 'product'
(product
details page), or 'other'
.
inventory.onProductsFetched(cb)
¶
This function takes a callback that will provide you an object of products detected on the current page.
Events¶
The extension generates the following events:
Inventory/Product Page Viewed¶
oa.track('{{pageType}} viewed', {
url: "https://the-url.com/",
product_ids: ['list', 'of', 'detected', 'product', 'ids'],
});
This event does not fire if the pageType
is 'other'
.
Listening¶
This extension does not listen for any events in the SDK.
Dependencies¶
This extension does not depend on any other extensions.