Fanplayr 360
  • Introduction
  • Data
  • Navigation
  • Tutorials
    • Sync High Value Users to Facebook Custom Audience
  • Features
    • Overview
    • Filters
      • Examples
    • Insights
    • Audiences
      • List
      • Editing
    • Automations
      • List
      • Editing
    • Pipelines
      • List
      • Editing
    • Exports
      • List
      • Editing
    • Profiles
      • Profile
  • 🔗Integrations
    • Sources
      • List
      • Editing
    • Destinations
      • List
      • Editing
    • Catalog
      • Amplitude
      • Attentive
      • AWS S3
      • Cordial
      • Custom Integration
      • Facebook Custom Audience
      • FTP/SFTP - Password Authentication
      • Google Ads
      • JavaScript
      • Mailchimp
      • Mailup
      • Pipedrive
      • Salesforce Commerce Cloud
      • Salesforce Marketing Cloud
      • Send In Blue
      • SFTP - SSH Key Authentication
      • Shopify
      • Slack
      • TikTok
      • Twilio
      • VTEX IO
  • Other
    • Mapping
      • Events
      • Event Attributes
    • Data Dictionary
      • Events
      • Event Attributes
      • User Attributes
    • Data Health
    • Compliance
      • PII
      • Consent
    • Account Settings
      • Personal
      • Preferences
      • Company
      • Users
      • Security
      • Invoices
  • 👩‍💻API Reference
    • API Overview
    • JavaScript API
      • Javascript API Reference
    • Custom API
      • Sessions and Users
      • Tracking Page Views
      • Tracking Events
      • Managing Identity
      • User Profile Data
      • Managing Consent
    • Semantic Data
      • Semantic Events
        • E-Commerce
        • Messaging
        • Other
      • Semantic Objects
      • Semantic User Attributes
      • Fanplayr 360 Generated Attributes
  • PrivacyID
  • Appendix
    • Terminology
Powered by GitBook
On this page
  • API Reference
  • consent.set
  • consent.unset
  • flush
  • identify
  • init
  • page
  • track
  • user.set
  • user.setOnce
  • user.unset
  • user.increment
  • setConfig
  • setSessionId
  • setUserId
  • Config Reference
  1. API Reference
  2. JavaScript API

Javascript API Reference

PreviousJavaScript APINextCustom API

Last updated 1 year ago

API Reference

Once you have installed the Fanplayr 360 library you will have access to a global variable window.fp360.

This object will have the following functions.

consent.set

fp360.consent.set(consentKey:string, consentValue:string, {
    purpose: Array<{
        type: string,
        topics?: string[]
    }>
}?);

consent.unset

fp360.consent.unset(consentKey:string, consentValue:string);

flush

fp360.flush(function() {
  // Fanplayr 360's events have been successfully tracked and the user can
  // be navigated to another page.
});

identify

fp360.identify({
  [identifyKey: string]: string
})

init

fp360.init({
  writeKey: string
  endpoint: string
  autoStartSession: boolean = false
  batchFlushDelayMs: number = 1000 // 1 second
  sessionDurationMs: number = 45 * 60 * 1000, // 45 minutes
  cookieExpiration: number = 365 // 1 year
  storageKey: string = 'fp360'
  storageType: 'localStorage'
  idMaxAgeMs: number = 60 * 60 * 1000, // 1 hour
  ip: boolean = true
  debug: true | false | 'none' | 'info' | 'verbose' = false
});

page

fp360.page({
    type: string,
    name?: string
})

track

fp360.track(eventName: string, {
    [attributeKey: string]: string | number | boolean | {
        [semanticAttributeKey:string]: string | number | boolean
    }
})

user.set

fp360.user.set({
    [userAttributeKey: string]: string | number | boolean
}, { expires: string, number, Date }?)

If you are only setting a single value you can call it like this:

fp360.user.set(
    userAttributeKey: string,
    value: string | number | boolean,
    { expires: string, number, Date }?
)

user.setOnce

fp360.user.setOnce({
    [userAttribute: string]: string | number | boolean
}, { expires: string, number, Date }?)

If you are only setting a single value you can call it like this:

fp360.user.setOnce(
    userAttributeKey: string,
    value: string | number | boolean,
    { expires: string, number, Date }?
)

user.unset

You can unset multiple values at once:

fp360.user.unset(userAttributeKeys: string[])

Or a single value:

fp360.user.unset(userAttributeKey: string)

user.increment

fp360.increment(userAttributeKey: string, value:number = 1)

setConfig

fp360.setConfig({
  writeKey: string
  endpoint: string
  autoStartSession: boolean = false
  batchFlushDelayMs: number = 1000 // 1 second
  sessionDurationMs: number = 45 * 60 * 1000, // 45 minutes
  cookieExpiration: number = 365 // 1 year
  storageKey: string = 'fp360'
  storageType: 'localStorage'
  idMaxAgeMs: number = 60 * 60 * 1000, // 1 hour
  ip: boolean = true
  debug: true | false | 'none' | 'info' | 'verbose' = false
});

setSessionId

fp360.setSessionId(sessionId: string)

setUserId

fp360.setUserId(uniqueUserId: string);

Config Reference

{
  // The write key generated from a Source integration.
  writeKey: string
  // The tracking endpoint to use, will differ depending on data storage region.
  endpoint: string
  // Whether to enable debug logging in the browser console.
  // Values `false` and `'none'` turn debugging off
  debug: true | false | 'none' | 'info' | 'verbose' = false
  // Set to `false` if using with Fanplayr Targeting.
  autoStartSession: boolean = true
  // The delay before sending batches of tracking data.
  batchFlushDelayMs: number = 1000 // 1 second
  // How long should a session last after last event.
  sessionDurationMs: number = 45 * 60 * 1000, // 45 minutes
  // How long the cookie should last - most browsers will ignore this.
  cookieExpiration: number = 365 // 1 year
  // The key in localStorage to store local Fanplayr 360 data.
  storageKey: string = 'fp360'
  // Where to store local data.
  storageType: 'localStorage'
  // The maximum duration to cache calls to `identify()`. This cache prevents
  // unnecessary requests when the `identify()` API is repeated with the same input.
  idMaxAgeMs: number = 60 * 60 * 1000, // 1 hour
  // When enabled, Fanplayr will use the client's IP address to determine geolocation.
  ip: boolean = true
}
👩‍💻
initialized