🛡️
PrivacyID
  • Introduction
  • User Interface Guide
  • Integration Guide
    • Implementing the API endpoint
    • Configuring the DNS entry
    • Installing the embed snippet
    • Using PrivacyID with third-party clients
    • Architecture
  • JavaScript API
  • Frequently Asked Questions
Powered by GitBook
On this page

Was this helpful?

  1. Integration Guide

Using PrivacyID with third-party clients

You will be ready to start using PrivacyID to obtain unique and consistent user IDs for your third-party clients and services once you have completed the other integration steps above.

The following pattern can be used to obtain a user ID anywhere after the PrivacyID embed snippet has been included on the page. Be sure to replace SCRIPT_KEY with the actual value shown in the PrivacyID Portal.

<script>
PrivacyID('getIdentity', 'SCRIPT_KEY', function(userId) {
  // Do something with 'userId'
});
</script>

Here’s an example of how this can be used to generate a consistent user identifier for Google Analytics:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1234567890"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-1234567890');
  
  PrivacyID('getIdentity', 'XXXX-XXXX-XXXX-XXXX', function(userId) {
    gtag('config', 'G-XXXXXXXXXX', {
      'user_id': userId
    });
  });
</script>
PreviousInstalling the embed snippetNextArchitecture

Last updated 2 years ago

Was this helpful?