diff --git a/README.md b/README.md index e8efa22..8140d7f 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ The tracking pixel instance is available on all vue component instances as $fb. |-------------------|----------------------------------------------------------------------------------------------------------|--------------------------------| | enable() | If you had previously set `disabled: true` in config, enables the pixel and tracks the current page view | $fb.init(), $fb.track() | | init() | Initialises the pixel | fbq('init', ) | -| track() | Sends a track event | fbq('track', ) | -| query(key, value) | Call the underlying fbq instance with anything else | fbq(key, value) | +| track(event) | Sends a track event. It's `PageView` by default if the `event` is not defined. | fbq('track', ) | +| query(key, value, parameters) | Call the underlying fbq instance with anything else. The `parameters` attribute is optional. | fbq(key, value, parameters) | ## License diff --git a/lib/templates/plugin.js b/lib/templates/plugin.js index 8367bc2..a91acb7 100644 --- a/lib/templates/plugin.js +++ b/lib/templates/plugin.js @@ -25,21 +25,26 @@ class Fb { /** * @method track */ - track (event = null) { + track (event = null, parameters = null) { if (!event) { event = this.options.track } - this.query('track', event) + this.query('track', event, parameters) } /** * @method query * @param {string} cmd * @param {object} option + * @param {object} parameters */ - query (cmd, option) { - this.fbq(cmd, option) + query (cmd, option, parameters = null) { + if (!parameters) { + this.fbq(cmd, option) + } else { + this.fbq(cmd, option, parameters) + } } }