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 tabAuthenticated 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,
});Identify modes
Identify can either only update existing users or also create new users who do not exist yet. This behavior is controlled by an Identify mode.
There are two modes: update (update-only, recommended default) and upsert (create or update, for special cases). When Identify runs in update mode, no new users are created unexpectedly.
If you do not pass a mode in your Identify call, Canny uses your company's default Identify mode, which is update in most cases. You can change this in your admin security settings under the Identify tab.
In almost all integrations, you should stick with update so that Identify never creates users on its own. You only need upsert when you want to pre-create users so they appear in the user search for your team to manually create insights or votes on their behalf.
Note that users who first reach Canny by following a link from your product will still be created automatically, regardless of the Identify mode you choose.
Canny('identify', {
appID: 'YOUR_APP_ID',
user: {
email: user.email,
id: user.id,
name: user.name,
},
});