Skip to content

Instantly share code, notes, and snippets.

@gooley gooley/zendesk.html
Last active Aug 29, 2015

Embed
What would you like to do?
Zendesk Helpcenter Instrumentation
// document head
// Put this script block inside the template for your document head, it will load and initialize the Preact logging javascript
<script>
window._preactq = window._preactq || [];
window._preactq.push(['_setCode', 'your_project_code']);
$(function(){
if(HelpCenter.user){
window._preactq.push(['_setPersonData', {
name: HelpCenter.user.name,
email: HelpCenter.user.email
}]);
(function() {
var preact = document.createElement('script'); preact.type = 'text/javascript'; preact.async = true;
preact.src = 'https://s3.amazonaws.com/lessneglect-cdn-01/js/preact-4.0.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(preact, s);
})();
}
});
</script>
// put each of these script tags in the page template specified by the comment preceding it.
// home
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-home' }]); });</script>
// category
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-category', note: '{{title}}' }]); });</script>
// section
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-section', note: '{{title}}' }]); });</script>
// article
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-article', note: '{{title}}' }]); });</script>
// contributions
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-contributions' }]); });</script>
// following
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-following' }]); });</script>
// my requests
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-my-requests' }]); });</script>
// single request
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-request', target_id: '{{request_id}}', note: '{{subject}}' }]); });</script>
// new request
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-new-request' }]); });</script>
// search results
<script>$(function(){ _preactq.push(['_logEvent', { name: 'zendesk-helpcenter|viewed:helpcenter-search-results' }]); });</script>
// error
<script>$(function(){ _preactq.push(['_logEvent', { name: '!zendesk-helpcenter|errored:helpcenter-page', note: '{{error_message}}' }]); });</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.