接入

npm install @fingerprintjs/fingerprintjs-pro

<script>
  // Initialize the agent at application startup.
  const fpPromise = new Promise((resolve, reject) => {
    const script = document.createElement('script')
    script.onload = resolve
    script.onerror = () => reject('Failed to load the script')
    script.async = true
    script.src = 'https://cdn.jsdelivr.net/npm/'
      + '@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js'
    document.head.appendChild(script)
  })
    .then(() => FingerprintJS.load({
      // Get a token at https://dashboard.fingerprintjs.com
      // Wait a couple of seconds before a result appears
      token: 'sample_docs_token',
      // region: 'eu',
      // endpoint: 'https://fp.your.com',
    }))

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp => fp.get(
      /* { linkedId: 'your-linked-id', tag: { yourTag: 123456 } } */
    ))
    .then(result => {
      const visitorId = result.visitorId
      console.log('Your visitorId:', visitorId)
    })
    .catch(error => console.error(error))
</script>

npm接入代码:

import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'

// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({
  token: 'sample_docs_token',
  region: 'eu' //ap eu 
})

// Get the visitor identifier when you need it.
fpPromise
  .then(fp => fp.get())
  .then(result => console.log(result.visitorId))

服务端

177.png
检查用户visitorId:
https://api.fpjs.io/visitors/someVisitorID?token=token
其中,

  • https://eu.api.fpjs.io for EU
  • https://ap.api.fpjs.io for Asia (Mumbai)

用户标注

使用tag和link-id区分,tag分组,link-id细分uid

import FingerprintJS from '@fingerprintjs/fingerprintjs-pro'

// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({ token: 'token' })

// Get the visitor identifier when you need it.
fpPromise
  .then(fp => fp.get({ linkedId: 'your-linked-id', tag: { yourTag: 123456 } }))
  .then(result => console.log(result.visitorId))
<script>
  // Initialize the agent at application startup.
  const fpPromise = new Promise((resolve, reject) => {
    const script = document.createElement('script');
    script.onload = resolve;
    script.onerror = reject;
    script.async = true;
    script.src = 'https://cdn.jsdelivr.net/npm/'
      + '@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js';
    document.head.appendChild(script);
  }).then(() =>
    FingerprintJS.load({ token: '' })
  );

  // Get the visitor identifier when you need it.
  fpPromise
    .then(fp => fp.get({ linkedId: 'your-linked-id', tag: { yourTag: 123456 }})
    .then(result => console.log(result.visitorId));
</script>

自定义数据上报域名

有时候adblock可能会屏蔽fp的域名,我们可以在后台自定义域名(需要申请ssl)
178.png
按要求先解析cname过去,然后耐心等待SSL签发,检测很快就会通过。
179.png
出来两个亚马逊BGP的IP,并告诉我们如何指定endpoint:

FingerprintJS.load({token: '', endpoint: 'https://endpoint'})

暂时更新这么多, fingerprintjspro的dashboard bug真不少,之前注册接入域名的时候卡住了,提交不了。后续从激活链接点入的就可以了,不过界面做的还倒是不错。