Subscriber Systems and CDPs

256

Integrating ATS with Piano.io

Piano.io exposes an event that is fired when a user logs in. By assigning a function to this parameter, you can obtain the user's login identifiers.

tp = window.tp || [];
tp.push(['setUsePianoIdUserProvider', true]);
tp.push(["init", function() {
    tp.pianoId.init({
        displayMode: 'inline',
        containerSelector: '#login-form',
        loggedIn: function(data) {
            console.log('user ', data.user, ' logged in with token', data.token);
        },
        loggedOut: function() {
            console.log('user logged out');
        }
    });
}]);

The important parameter is loggedIn which is mapped to an anonymous function to parse data. By accessing user.data.email, you should be able to obtain the email address that the user logged in with, then pass it to ATS, e.g.

tp = window.tp || [];
tp.push(['setUsePianoIdUserProvider', true]);
tp.push(["init", function() {
    tp.pianoId.init({
        displayMode: 'inline',
        containerSelector: '#login-form',
        loggedIn: function(data) {
            if (data){
              window.ats.start({
                "placementID":9999.
                "storageType": "cookie",
                "email": data.user.email,
                "logging":"error"
              });
            }
        },
        loggedOut: function() {
            console.log('user logged out');
        }
    });
}]);

See piano.io documentation for more information.