### Install and Configure Woopra Tracker (HTML)
Source: https://github.com/woopra/browser-tracker/blob/master/README.md
This snippet demonstrates how to install and configure the Woopra Browser Tracker. It should be placed in the HEAD section of your HTML document before any Woopra function calls. The tracker loads asynchronously and processes commands after the script is loaded. It includes basic configuration for the domain and tracks an initial pageview.
```html
```
--------------------------------
### Woopra Tracker Installation and Basic Usage
Source: https://context7.com/woopra/browser-tracker/llms.txt
This snippet shows how to load the Woopra tracker asynchronously and perform basic configuration and pageview tracking.
```APIDOC
## Woopra Tracker Installation and Basic Usage
### Description
Load the Woopra tracker asynchronously in your HTML document's HEAD section for optimal performance. This example demonstrates basic tracker loading, configuration with a domain, and tracking a pageview.
### Method
Asynchronous Script Loading, `woopra.config()`, `woopra.track()
### Endpoint
N/A (Client-side JavaScript SDK)
### Parameters
#### Request Body (for `woopra.config()`)
- **domain** (string) - Required - The domain of your website for tracking.
### Request Example
```html
```
### Response
#### Success Response (200)
N/A (Client-side SDK)
#### Response Example
N/A
```
--------------------------------
### Configure Woopra Browser Tracker
Source: https://context7.com/woopra/browser-tracker/llms.txt
Initializes the Woopra tracker with specific settings for domain, cookies, event tracking, and protocol. This configuration should be applied before tracking events to ensure consistent data collection.
```javascript
woopra.config({
domain: 'mybusiness.com',
beacons: true,
cookie_name: 'wooTracker',
cookie_domain: '.mybusiness.com',
cookie_path: '/',
cookie_expire: new Date(),
cookie_secure: true,
click_tracking: false,
click_tracking_matcher_selectors: ['a', 'button', 'input[type=button]', 'input[type=submit]', '[role=button]'],
click_pause: 250,
download_tracking: false,
download_extensions: ['avi', 'css', 'dmg', 'doc', 'exe', 'mp3', 'pdf', 'rar', 'zip'],
download_pause: 200,
outgoing_tracking: false,
outgoing_pause: 200,
outgoing_ignore_subdomain: true,
form_pause: 250,
ping: false,
ping_interval: 12000,
ignore_query_url: true,
save_url_hash: true,
hide_campaign: false,
map_query_params: {},
personalization: true,
protocol: 'https',
tracking_domain: null,
cross_domain: false
});
```
--------------------------------
### Implement Cross-Domain Tracking with woopra.decorate()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Enables seamless visitor identification across multiple domains by decorating URLs with the visitor's cookie ID. Configuration requires setting the main domain and an array of cross-domain domains. It provides functions to manually decorate/undecorate URLs and automatically handles decoration for links to configured domains.
```javascript
woopra.config({
domain: 'mybusiness.com',
cross_domain: ['app.mybusiness.com', 'shop.mybusiness.com']
});
const decoratedUrl = woopra.decorate('https://app.mybusiness.com/dashboard');
console.log(decoratedUrl);
const link = document.querySelector('a.cross-domain-link');
link.href = woopra.decorate(link);
const cleanUrl = woopra.undecorate('https://app.mybusiness.com/dashboard?__woopraid=abc123xyz');
console.log(cleanUrl);
```
--------------------------------
### Configure and Run Mocha Tests
Source: https://github.com/woopra/browser-tracker/blob/master/test/index.html
Sets up the Mocha testing environment for the Woopra browser tracker. It configures global variables, runs the tests, and captures results, including reporting failed tests.
```javascript
mocha.ui('bdd');
var exports = exports || window;
onload = function() {
//mocha.checkLeaks();
//mocha.globals(['foo']);
if (navigator.userAgent.indexOf('PhantomJS') < 0) {
var runner = mocha
.globals(['_w', 'woopra', 'newTracker', 'mochaResults'])
.run();
var failedTests = [];
runner.on('end', function() {
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
function logFailure(test, err) {
var flattenTitles = function(test) {
var titles = [];
while (test.parent.title) {
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
};
failedTests.push({
name: test.title,
result: false,
message: err.message,
stack: err.stack,
titles: flattenTitles(test)
});
}
runner.on('fail', logFailure);
}
};
```
--------------------------------
### Configure Woopra Tracker Options
Source: https://context7.com/woopra/browser-tracker/llms.txt
Configures the Woopra tracker with various options such as domain, cookie settings, tracking behaviors, and timing intervals. It demonstrates configuring with an object, a single option, and reading a configuration value.
```javascript
// Configure with object of options
woopra.config({
domain: 'mybusiness.com',
cookie_name: 'my_business_cookie',
cookie_domain: '.mybusiness.com',
cookie_expire: new Date(new Date().setFullYear(new Date().getFullYear() + 2)),
cookie_path: '/',
cookie_secure: true,
ping: true,
ping_interval: 12000,
download_tracking: true,
download_extensions: ['pdf', 'zip', 'dmg', 'exe'],
download_pause: 200,
outgoing_tracking: true,
outgoing_pause: 200,
outgoing_ignore_subdomain: true,
click_tracking: true,
click_tracking_matcher_selectors: ['a', 'button', 'input[type=button]', 'input[type=submit]', '[role=button]'],
click_pause: 250,
form_pause: 250,
ignore_query_url: false,
hide_campaign: false,
map_query_params: { ref: 'campaign_name', src: 'campaign_source' },
protocol: 'https',
personalization: true,
beacons: true
});
// Configure single option
woopra.config('cookie_name', 'custom_tracker_cookie');
// Read configuration value
const currentDomain = woopra.config('domain');
console.log('Tracking domain:', currentDomain);
```
--------------------------------
### Manage Visit Data with woopra.visit()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Attaches custom data to the current session or visit that persists across pageviews but is not permanently tied to the visitor profile. It can be used to set multiple properties, a single property, or retrieve all current visit properties. Input is typically an object of key-value pairs or a string key and value.
```javascript
woopra.visit({
landing_page: '/home',
referrer_campaign: 'spring_sale',
ab_test_variant: 'B',
session_source: 'email'
});
woopra.visit('entry_point', 'pricing_page');
const visitData = woopra.visit();
console.log('Current visit data:', visitData);
```
--------------------------------
### woopra.visit()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Attaches custom session or visit data that persists across pageviews but is not permanently tied to the visitor profile.
```APIDOC
## JS woopra.visit()
### Description
Attach custom session/visit data that persists across pageviews but doesn't stick to the visitor profile permanently.
### Method
Client-side JS Method
### Parameters
- **properties** (object/string) - Optional - Key-value pairs of visit data, or a single key string.
- **value** (any) - Optional - The value to set if the first parameter is a key string.
### Request Example
woopra.visit({ landing_page: '/home', session_source: 'email' });
### Response
- **object** - Returns the current visit properties object when called without arguments.
```
--------------------------------
### woopra.decorate()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Decorates URLs with visitor cookie IDs to enable seamless visitor identification across multiple domains.
```APIDOC
## JS woopra.decorate()
### Description
Decorate URLs for cross-domain tracking by appending the visitor's cookie ID. This enables seamless visitor identification across multiple domains.
### Method
Client-side JS Method
### Parameters
- **url** (string/element) - Required - The URL string or anchor element to decorate.
### Request Example
const decoratedUrl = woopra.decorate('https://app.mybusiness.com/dashboard');
### Response
- **string** - Returns the URL with the __woopraid parameter appended.
```
--------------------------------
### woopra.config() - Tracker Configuration
Source: https://context7.com/woopra/browser-tracker/llms.txt
Configure the Woopra tracker with various options to customize tracking behavior, cookie settings, and event monitoring.
```APIDOC
## woopra.config()
### Description
Configure the Woopra tracker with various options including domain, cookie settings, tracking behaviors, and timing intervals. The `config` function accepts either a key-value pair or an object of configuration options. It can also be used to read a configuration value.
### Method
`woopra.config(options)` or `woopra.config(key, value)` or `woopra.config(key)`
### Endpoint
N/A (Client-side JavaScript SDK)
### Parameters
#### Request Body (for `woopra.config(options)`)
- **domain** (string) - Required - The domain of your website for tracking.
- **cookie_name** (string) - Optional - The name for the Woopra visitor cookie.
- **cookie_domain** (string) - Optional - The domain for the Woopra visitor cookie.
- **cookie_expire** (Date) - Optional - The expiration date for the Woopra visitor cookie.
- **cookie_path** (string) - Optional - The path for the Woopra visitor cookie.
- **cookie_secure** (boolean) - Optional - Whether to use secure cookies.
- **ping** (boolean) - Optional - Enable visitor activity pings.
- **ping_interval** (number) - Optional - Interval in milliseconds for visitor activity pings.
- **download_tracking** (boolean) - Optional - Enable automatic download tracking.
- **download_extensions** (Array) - Optional - File extensions to track as downloads.
- **download_pause** (number) - Optional - Delay in milliseconds before tracking a download.
- **outgoing_tracking** (boolean) - Optional - Enable automatic outgoing link tracking.
- **outgoing_pause** (number) - Optional - Delay in milliseconds before tracking an outgoing link.
- **outgoing_ignore_subdomain** (boolean) - Optional - Ignore outgoing links to subdomains.
- **click_tracking** (boolean) - Optional - Enable automatic click tracking.
- **click_tracking_matcher_selectors** (Array) - Optional - CSS selectors for elements to track clicks on.
- **click_pause** (number) - Optional - Delay in milliseconds before tracking a click.
- **form_pause** (number) - Optional - Delay in milliseconds before tracking a form submission.
- **ignore_query_url** (boolean) - Optional - Whether to ignore query parameters in URLs.
- **hide_campaign** (boolean) - Optional - Whether to hide campaign information from URLs.
- **map_query_params** (Object) - Optional - Map query parameters to Woopra campaign variables.
- **protocol** (string) - Optional - The protocol to use for tracking requests (e.g., 'https').
- **personalization** (boolean) - Optional - Enable personalization features.
- **beacons** (boolean) - Optional - Enable beacon technology for event delivery.
#### Path Parameters
N/A
#### Query Parameters
N/A
### Request Example
```javascript
// Configure with object of options
woopra.config({
domain: 'mybusiness.com',
cookie_name: 'my_business_cookie',
cookie_domain: '.mybusiness.com',
cookie_expire: new Date(new Date().setFullYear(new Date().getFullYear() + 2)),
cookie_path: '/',
cookie_secure: true,
ping: true,
ping_interval: 12000,
download_tracking: true,
download_extensions: ['pdf', 'zip', 'dmg', 'exe'],
download_pause: 200,
outgoing_tracking: true,
outgoing_pause: 200,
outgoing_ignore_subdomain: true,
click_tracking: true,
click_tracking_matcher_selectors: ['a', 'button', 'input[type=button]', 'input[type=submit]', '[role=button]'],
click_pause: 250,
form_pause: 250,
ignore_query_url: false,
hide_campaign: false,
map_query_params: { ref: 'campaign_name', src: 'campaign_source' },
protocol: 'https',
personalization: true,
beacons: true
});
// Configure single option
woopra.config('cookie_name', 'custom_tracker_cookie');
// Read configuration value
const currentDomain = woopra.config('domain');
console.log('Tracking domain:', currentDomain);
```
### Response
#### Success Response (200)
- **configuration_value** (any) - The value of the requested configuration option if reading, otherwise void.
#### Response Example
```javascript
// Example of reading a configuration value
console.log('Tracking domain:', 'mybusiness.com');
```
```
--------------------------------
### Push Visitor Identification Data with woopra.push()
Source: https://context7.com/woopra/browser-tracker/llms.txt
The `woopra.push()` method sends visitor identification data to Woopra servers without tracking an event. This is useful for identifying users without triggering a pageview or custom event. It can be chained after `woopra.identify()` and supports callbacks.
```javascript
woopra.identify({
email: 'johndoe@mybusiness.com',
name: 'John Doe',
company: 'My Business'
}).push();
woopra.identify({
email: 'jane@example.com',
name: 'Jane Smith'
}).push(function() {
console.log('Visitor data pushed to Woopra');
});
woopra.identify('email', 'user@domain.com').push();
```
--------------------------------
### Configure Woopra Tracker Settings
Source: https://github.com/woopra/browser-tracker/blob/master/README.md
Configure the Woopra tracker using either a key-value pair or an object of settings. These settings control various aspects of tracking behavior, such as cookie names and tracking intervals.
```javascript
woopra.config('cookie_name', 'my_business_cookie');
```
```javascript
woopra.config({
download_tracking: false,
outgoing_tracking: false,
ping_interval: 30000
});
```
--------------------------------
### Track Pageviews and Custom Actions
Source: https://github.com/woopra/browser-tracker/blob/master/README.md
Track standard pageviews or custom actions with associated properties. The track function can be called without arguments for a default pageview or with event names and properties for custom actions.
```javascript
woopra.track();
```
```javascript
// The line above is equivalent to
woopra.track('pv', {
url: window.location.pathname + window.location.search,
title: document.title
});
```
```javascript
woopra.track(
'signup',
{
company: 'My Business',
username: 'johndoe',
plan: 'Gold'
},
function (action) {
// track request successfully sent to Woopra
}
);
```
```javascript
document.getElementById('play-button').onclick = function () {
woopra.track('play', {
artist: 'Dave Brubeck',
song: 'Take Five',
genre: 'Jazz'
});
};
```
--------------------------------
### Identify Customer with Visitor Properties
Source: https://github.com/woopra/browser-tracker/blob/master/README.md
Identify a customer by sending their email and other relevant details as custom visitor properties before tracking an event. This allows Woopra to use the email as a unique identifier instead of cookies.
```javascript
// Identify customer before the track event
woopra.identify({
email: 'johndoe@mybusiness.com',
name: 'John Doe',
company: 'My Business'
});
```
```javascript
woopra.identify('email', 'johndoe@mybusiness.com').push();
```
--------------------------------
### Track Pageviews and Custom Events with woopra.track()
Source: https://context7.com/woopra/browser-tracker/llms.txt
The `woopra.track()` method allows for tracking pageviews and custom events with optional properties and callbacks. When called without arguments, it tracks a pageview of the current page. Custom events can include any properties relevant to the action, and callbacks can be provided for success, error, or before-send events.
```javascript
woopra.track();
woopra.track('pv', {
url: '/custom/page/path',
title: 'Custom Page Title'
});
woopra.track('signup', {
company: 'My Business',
username: 'johndoe',
plan: 'Gold',
value: 99.99
});
woopra.track('purchase', {
product: 'Pro Subscription',
price: 299,
currency: 'USD'
}, function(action) {
console.log('Purchase tracked successfully');
});
woopra.track('video_play', {
artist: 'Dave Brubeck',
song: 'Take Five',
genre: 'Jazz',
duration: 324
}, {
onSuccess: function(action) {
console.log('Event tracked:', action.id);
},
onError: function(action) {
console.error('Tracking failed');
},
onBeforeSend: function(action) {
console.log('About to send:', action.params);
},
timeout: 300000,
lifecycle: 'action',
queue: true,
useBeacon: true
});
woopra.track('article_read', {
article_id: 'post-123',
category: 'Technology'
}, {
lifecycle: 'page',
retrack: true,
timeout: 60000
});
```
--------------------------------
### Identify Visitors with Custom Properties
Source: https://context7.com/woopra/browser-tracker/llms.txt
Identifies visitors with custom properties like email, name, and company before tracking events. It shows identification using an object, a key-value pair, and combined visitor/organization identification.
```javascript
// Identify with object of properties
woopra.identify({
email: 'johndoe@mybusiness.com',
name: 'John Doe',
company: 'My Business',
plan: 'Enterprise',
role: 'Administrator',
signup_date: '2024-01-15'
});
// Identify with key-value pair
woopra.identify('email', 'johndoe@mybusiness.com');
// Identify visitor and organization together
woopra.identify(
{ email: 'johndoe@mybusiness.com', name: 'John Doe' },
{ id: 'org_12345', name: 'My Business', industry: 'Technology' }
);
// Identify visitor with organization using key-value format
woopra.identify(
'email', 'johndoe@mybusiness.com',
{ id: 'org_12345', name: 'Acme Corp' }
);
```
--------------------------------
### Track Clicks with woopra.trackClick()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Tracks user clicks on specific HTML elements, allowing for custom event names and properties. It can handle single or multiple elements and offers options for callbacks and navigation behavior. Dependencies include the Woopra tracker script. It takes an event name, a selector or element(s), and optional properties and configuration.
```javascript
woopra.trackClick('button_clicked', '#cta-button', {
button_name: 'Get Started',
location: 'homepage'
});
woopra.trackClick('download_clicked', '.download-btn', {
file_type: 'pdf',
document_name: 'User Guide'
}, {
callback: function(properties) {
console.log('Click tracked:', properties);
},
onBeforeSend: function() {
console.log('Tracking click...');
},
noNav: false
});
woopra.trackClick('product_clicked', {
elements: document.querySelectorAll('.product-card'),
callback: function(props) {
console.log('Product clicked');
}
});
// HTML:
// Automatically tracks event "premium_cta" with property plan="enterprise"
woopra.config({ click_tracking: true });
```
--------------------------------
### woopra.trackClick()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Tracks clicks on specific elements with custom event names and properties, ensuring events are captured before navigation.
```APIDOC
## JS woopra.trackClick()
### Description
Tracks clicks on specific elements with custom event names and properties. The tracker handles click timing and ensures events are sent before navigation.
### Method
Client-side JS Method
### Parameters
- **event_name** (string) - Required - The name of the event to track.
- **selector** (string/object) - Required - CSS selector or element object to attach the click listener.
- **properties** (object) - Optional - Custom properties to attach to the event.
- **options** (object) - Optional - Configuration for callback, onBeforeSend, and navigation behavior.
### Request Example
woopra.trackClick('button_clicked', '#cta-button', { button_name: 'Get Started' });
### Response
- **void** - This method does not return a value but triggers an asynchronous tracking request.
```
--------------------------------
### woopra.identify() - Visitor Identification
Source: https://context7.com/woopra/browser-tracker/llms.txt
Identify visitors with custom properties such as email, name, and company to associate data with specific user profiles.
```APIDOC
## woopra.identify()
### Description
Identify visitors with custom properties such as email, name, and company. These properties are associated with the visitor and displayed in Woopra profiles. The `identify` function should be called before tracking events to attach visitor data. It can accept visitor properties, organization properties, or both.
### Method
`woopra.identify(visitorProperties)` or `woopra.identify(visitorKey, visitorValue, [organizationProperties])` or `woopra.identify(visitorProperties, organizationProperties)`
### Endpoint
N/A (Client-side JavaScript SDK)
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
- **visitorProperties** (Object or string) - Required - An object containing key-value pairs of visitor properties (e.g., `email`, `name`, `plan`) or a single key-value pair string.
- **organizationProperties** (Object) - Optional - An object containing key-value pairs of organization properties (e.g., `id`, `name`, `industry`).
### Request Example
```javascript
// Identify with object of properties
woopra.identify({
email: 'johndoe@mybusiness.com',
name: 'John Doe',
company: 'My Business',
plan: 'Enterprise',
role: 'Administrator',
signup_date: '2024-01-15'
});
// Identify with key-value pair
woopra.identify('email', 'johndoe@mybusiness.com');
// Identify visitor and organization together
woopra.identify(
{ email: 'johndoe@mybusiness.com', name: 'John Doe' },
{ id: 'org_12345', name: 'My Business', industry: 'Technology' }
);
// Identify visitor with organization using key-value format
woopra.identify(
'email', 'johndoe@mybusiness.com',
{ id: 'org_12345', name: 'Acme Corp' }
);
```
### Response
#### Success Response (200)
N/A (Client-side SDK)
#### Response Example
N/A
```
--------------------------------
### Automatically Track Form Submissions with woopra.trackForm()
Source: https://context7.com/woopra/browser-tracker/llms.txt
The `woopra.trackForm()` method automatically tracks form submissions, capturing form field data. It can optionally identify the visitor based on form data and handles form submission timing. Callbacks and options like `noSubmit` can be configured.
```javascript
woopra.trackForm('contact_form_submitted', '#contact-form');
woopra.trackForm('signup_form', '#signup-form', {
identify: function(formData) {
return {
email: formData.email,
name: formData.first_name + ' ' + formData.last_name
};
},
callback: function(properties) {
console.log('Form tracked with properties:', properties);
},
onBeforeSend: function() {
console.log('About to track form submission');
},
onError: function() {
console.error('Form tracking failed');
},
noSubmit: false
});
woopra.trackForm('newsletter_signup', {
elements: document.querySelectorAll('form.newsletter'),
identify: function(data) {
return { email: data.email };
}
});
```
--------------------------------
### Reset Visitor Tracking with woopra.reset()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Resets the visitor's tracking cookie, forcing the generation of a new visitor ID. This is commonly used during user logout or when a fresh tracking session is required. It can be used standalone or as part of a logout flow, potentially followed by identifying as anonymous and tracking a logout event.
```javascript
woopra.reset();
function handleLogout() {
woopra.reset();
woopra.identify({});
woopra.track('logout');
}
```
--------------------------------
### Update Tracked Actions with woopra.update()
Source: https://context7.com/woopra/browser-tracker/llms.txt
The `woopra.update()` method is used to update properties of an existing tracked action using its ID. This is useful for adding additional data to events after they've been initially tracked. It can also be called on an action object returned by `woopra.track()`.
```javascript
woopra.track('form_started', {
form_name: 'Contact Form'
}, {
onSuccess: function(action) {
window.currentFormAction = action;
action.update({
field_count: 5,
estimated_time: '2 minutes'
});
}
});
woopra.update('action_id_123', {
completed_fields: 3,
progress: 60
});
woopra.update('action_id_123', {
status: 'completed'
}, {
onSuccess: function() {
console.log('Action updated');
},
useBeacon: true
});
```
--------------------------------
### woopra.reset()
Source: https://context7.com/woopra/browser-tracker/llms.txt
Resets the visitor's tracking cookie to generate a new visitor ID, typically used during logout flows.
```APIDOC
## JS woopra.reset()
### Description
Reset the visitor's tracking cookie to generate a new visitor ID. This is useful when a user logs out or you need to start a fresh tracking session.
### Method
Client-side JS Method
### Request Example
woopra.reset();
### Response
- **void** - Clears the current visitor identification state.
```
--------------------------------
### Cancel Tracked Actions with woopra.cancelAction()
Source: https://context7.com/woopra/browser-tracker/llms.txt
The `woopra.cancelAction()` method cancels a tracked action, preventing it from updating durations or being retracked. This is useful when a user abandons an action or navigates away. Actions can be canceled directly by their ID or via the `cancel()` method on an action object.
```javascript
woopra.track('reading_article', {
article_id: 'post-456'
}, {
lifecycle: 'page',
onSuccess: function(action) {
document.getElementById('skip-btn').addEventListener('click', function() {
action.cancel();
});
}
});
woopra.cancelAction('action_id_789');
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.