If Custom Properties have been set when a user submits your survey, those values will be sent as meta data which will be visible in your reports.
The following code is an example of how you can catch times when the custom properties have not been set at the time a response is submitted. It also demonstrates how you can create your own check for the user properties you'd like to collect and set them when they're available.
Note: Depending on how you monitor JavaScript errors, you'll need to update the following code so messages are logged in your system.
function qualPropsEmptyError(survey_id) { _kiq.push(['getProperties', function(props) { if (Object.keys(props).length === 0) { throw (new Error('Qualaroo: Custom properties were empty for ' + survey_id)); } }]); } function pushQualCustomProps() { // Create your own check for whether your user data object is defined if (userIdKnown) { _kiq.push(['set', userObject ]); } } _kiq.push(['eventHandler', 'submit', function(answer, survey_id) { try { qualPropsEmptyError(survey_id) } catch (e) { console.log(e.message); pushQualCustomProps(); } }]);
Comments
0 comments
Article is closed for comments.