Setting transaction attributes
Plumbr Browser API allows setting following attributes of a transaction:
- Application
- Service
- User
These attributes can be set in two alternative ways: programmatically or via configuration parameters of the browser agent script. Selecting which way to use depends on the application type. Classic web applications, which generate HTML on the server side and have all the knowledge there may find it easier to generate required values for the configuration on the server side, eliminating the need for additional JavaScript code. Single page web applications, may find it more suitable to setup these attributes via direct JavaScript calls.
For information on configuration parameters please see the section on Browser Agent Configuration
Plumbr Browser API is exposed on window.PLUMBR
, so it can be accessed globally as PLUMBR
. It is recommended to wrap API calls in try…catch blocks to avoid situations where user-side blocking of the agent (such as privacy targeted browser addons) would crash your application.
document.getElementById('add-to-cart').addEventListener('click', function() { try { PLUMBR.setServiceName('add product to cart'); } catch(err) {} // ajax call to add product to cart... });
Available configuration options and API calls will be described below.