Advanced Identify Features
Identify callback
Once your users have been successfully identified, it can sometimes makes sense to perform a followup action. Identify accepts a callback argument which allows you to call a function when identify has completed.
The callback will called regardless of if identification was successful or it failed, and does not pass any arguments.
To find your appID, log in above. You'll see your appID pre‑filled in the code snippet.
function myCallback() {
console.log('The user was identified');
}
Canny('identify', {
appID: 'YOUR_APP_ID',
user: {
avatarURL: viewer.avatarURL, // optional
created: new Date(viewer.created).toISOString(), // optional
email: viewer.email,
id: viewer.id,
name: viewer.name,
},
}, myCallback);
Handling the routing to Canny yourself
You may need to perform other actions when a user clicks on your feedback link prior to redirecting them to your Canny board.
To do this, you can use the authenticateCannyLink function.
// Where YOUR_FEEDBACK_LINK is a URL to your Canny site, eg, 'http://feedback.canny.io'
const authenticatedLink = Canny('authenticateCannyLink', YOUR_FEEDBACK_LINK);
window.open(authenticatedLink, '_blank', 'noopener'); // open Canny in a new tab
Authenticated Links to Canny
By default, once a user has been identified using the Canny SDK, they will be automatically logged in when they navigate to a Canny page using a link in your app. This works because the SDK scans for Canny links and replaces them with secure, authenticated versions just before the user clicks them.
If you prefer more control over which links are authenticated, you can disable the authenticateLinks setting. When this setting is disabled, only a tags marked with the data-canny-link attribute, or links that have been manually configured withauthenticateCannyLink, will be converted to authenticated links.
Canny('identify', {
appID: 'YOUR_APP_ID',
user: {
avatarURL: viewer.avatarURL, // optional
created: new Date(viewer.created).toISOString(), // optional
email: viewer.email,
id: viewer.id,
name: viewer.name,
},
authenticateLinks: false,
});