We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

Audience integrations: LinkedIn

The LinkedIn integration enables linking of LinkedIn user IDs with Piano user IDs and can later be used for audience segments, reporting and targeting.


  1. For you to get the LinkedIn user ID of the current user, that user must log in to LinkedIn from the current page. This only needs to happen once (more info).

  2. Create a prefix to link the LinkedIn ID to it, e.g. 'lnk' (more info).

  3. Create a persisted query for /profile/user/external/link/update where you lock down the "type" to be your prefix and make "id" and "cxid" mutable (more info).

  4. (Optionally) The LinkedIn ID can be one-way hashed to remove the possibility of later getting a LinkedIn user from a Piano user ID.

  5. Add the below tag anywhere on the page (preferably earlier in the file to make sure that it is loaded before the user navigates somewhere else):

<!-- Piano LinkedIn user linking script begin -->
<script type="text/javascript">
    window.cX = window.cX || {}; cX.callQueue = cX.callQueue || [];
    cX.callQueue.push(['invoke', function() {
        var intervalId = setInterval(function() {
            if (window.IN && IN.User && typeof IN.User.isAuthorized === 'function' && IN.User.isAuthorized()) {
                clearInterval(intervalId);
 
                // Read the LinkedIn user ID
                var linkedInUserId = IN.User.getMemberId();
 
                // Map the LinkedIn user ID to the Cxense user ID
                var persistedQueryId = '<PERSISTED-QUERY-ID>'; // <-- TODO: Insert persisted query id here
                var apiUrl = 'https://api.cxense.com/profile/user/external/link/update?callback={{callback}}'
                    + '&persisted=' + encodeURIComponent(persistedQueryId)
                    + '&json=' + encodeURIComponent(cX.JSON.stringify({ id: linkedInUserId, cxid: cX.getUserId() }));
                cX.jsonpRequest(apiUrl, function (data) { /* If wanted, verify success here*/ });
            }
        }, 1000);
    }]);
    // Async load cx.js
    (function(d,s,e,t){e=d.createElement(s);e.type='text/java'+s;e.async='async';
        e.src='http'+('https:'===location.protocol?'s://s':'://')+'cdn.cxense.com/cx.js';
        t=d.getElementsByTagName(s)[0];t.parentNode.insertBefore(e,t);})(document,'script');
</script>
<!-- Piano LinkedIn user linking script end -->

Last updated: