Skip to main content
To install the SDK, please follow the instructions in the installation section. All methods below are called using the loaded window.gwhale instance.

init

This method needs to be called before calling any other methods below.
Used to initialize GuideWhale app environment and identify user, company and their membership.
  • For single page applications (SPA) this method should only be called when page is initially loaded.
  • For multipage application this method should be called on every page load
For a detailed parameter guide see the installation section.
environment_code
string
required
Code of the app environment to initialize. This can be found in our dashboard under Settings > Environments or Settings > Installation.
options
object
Initialization options, including user, company and membership properties.
Example
gwhale.init('prod-1234abcd', {
    gdpr: true,
    gdpr_consent: true,
    signature: '5e7001282790905aa22523e2c0c5e7cd08046b79fd8546b3bb43a5578704f683',
    user: {
        user_id: '123',
        email: '[email protected]',
        first_name: 'John',
        last_name: 'Smith',
        date_signed_up: '2022-01-01',
        custom_property: 'value1'
    },
    company: {
        company_id: '123',
        name: 'ACME',
        plan: 'Enterprise',
        date_signed_up: '2022-01-01',
        date_renewal: '2025-01-01',
        mrr: 999,
        license_count: 10,
        industry: 'Construction',
        size: 30,
        custom_property: 'value1'
    },
    membership: {
        is_primary: true,
        role: 'user',
        custom_property: 'value1'
    }
});

track

Used to programmatically track user events that are not taggable or automatically captured by GuideWhale.
name
string
required
The name of the event to track.
properties
object
Contextual properties associated with this event.
Example
gwhale.track('item_purchased', {
    name: 'Pro Subscription',
    price: 1000.0
});

onRedirect

Used to handle redirects without a page reload when GuideWhale content wants to redirect to another page.
handler
(url: string) => void
required
Handler function to handle redirects without a page reload when GuideWhale content wants to redirect to another page.
Example
gwhale.onRedirect((url: string) => {
    navigate(url);
});

reset

Remove currently identified user and company. You will have to call the init function again to re-identify the user.
Example
gwhale.reset();

setUserProperties

Helper function to set user properties of currently identified user without having to call the identify function again.
properties
object
required
New property values.
Example
gwhale.setUserProperties({
    completed_assignment: true
});

setCompanyProperties

Helper function to set company properties of currently identified user without having to call the identify function again.
properties
object
required
New property values.
Example
gwhale.setCompanyProperties({
    plan: 'Enterprise'
});

setMembershipProperties

Helper function to set user company membership properties of currently identified user without having to call the identify function again.
properties
object
required
New property values.
Example
gwhale.setMembershipProperties({
    position: 'Manager'
});