Skip to content

Javascript APIリファレンス

APIリファレンス

Fanplayr 360ライブラリをインストール (初期化)すると、グローバル変数 window.fp360 にアクセスできるようになります。

このオブジェクトには以下の関数が含まれます。

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

flush

typescript
fp360.flush(function() {
  // Fanplayr 360のイベントは正常にトラッキングされ、ユーザーは
  // 別のページに移動できます。
});

identify

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

init

typescript
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

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

track

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

user.set

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

単一の値を設定する場合、次のように呼び出すことができます。

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

user.setOnce

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

単一の値を設定する場合、次のように呼び出すことができます。

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

user.unset

複数の値を一度にアンセットできます。

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

または単一の値:

typescript
fp360.user.unset(userAttributeKey: string)

user.increment

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

setConfig

typescript
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

typescript
fp360.setSessionId(sessionId: string)

setUserId

typescript
fp360.setUserId(uniqueUserId: string);

設定リファレンス

typescript
{
  // Sourceインテグレーションから生成された書き込みキー。
  writeKey: string
  // 使用するトラッキングエンドポイント。データストレージリージョンによって異なります。
  endpoint: string
  // ブラウザのコンソールでデバッグログを有効にするかどうか。
  // `false` と `'none'` の値はデバッグをオフにします。
  debug: true | false | 'none' | 'info' | 'verbose' = false
  // Fanplayr Targetingと併用する場合は `false` に設定します。
  autoStartSession: boolean = true
  // トラッキングデータのバッチを送信するまでの遅延。
  batchFlushDelayMs: number = 1000 // 1 second
  // 最後のイベントからセッションがどのくらい続くべきか。
  sessionDurationMs: number = 45 * 60 * 1000, // 45 minutes
  // クッキーが持続する期間 - ほとんどのブラウザはこれを無視します。
  cookieExpiration: number = 365 // 1 year
  // Fanplayr 360のローカルデータを保存するためのlocalStorage内のキー。
  storageKey: string = 'fp360'
  // ローカルデータをどこに保存するか。
  storageType: 'localStorage'
  // `identify()`への呼び出しをキャッシュする最大期間。このキャッシュは
  // 同じ入力で`identify()` APIが繰り返された場合の不要なリクエストを防ぎます。
  idMaxAgeMs: number = 60 * 60 * 1000, // 1 hour
  // 有効にすると、FanplayrはクライアントのIPアドレスを使用して地理位置情報を判断します。
  ip: boolean = true
}