Copy & paste the code snippet below just before the closing </body> tag on the page you want to track.
<script type="text/javascript">
window.customerguru=window.customerguru||[],customerguru.load=function(t,e){window.customerguru.client_token=t,window.customerguru.config=e=e||{};var r=e.forceSSL||"https:"===document.location.protocol,u=document.createElement("script");u.type="text/javascript",u.async=!0,u.src=(r?"https:":"http:")+"//cdn.customer.guru/embed/v1.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(u,o);for(var c=function(){return function(){customerguru.push(Array.prototype.slice.call(arguments,0))}},n=["schedule"],s=0;s<n.length;s++)customerguru[n[s]]=c(n[s])};
customerguru.load("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY", { autoschedule: true, debug: true });
</script>
<script type="text/javascript">
window.customerguru=window.customerguru||[],customerguru.load=function(t,e){window.customerguru.client_token=t,window.customerguru.config=e=e||{};var r=e.forceSSL||"https:"===document.location.protocol,u=document.createElement("script");u.type="text/javascript",u.async=!0,u.src=(r?"https:":"http:")+"//cdn.customer.guru/embed/v1.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(u,o);for(var c=function(){return function(){customerguru.push(Array.prototype.slice.call(arguments,0))}},n=["schedule"],s=0;s<n.length;s++)customerguru[n[s]]=c(n[s])};
customerguru.load("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY", { scheduled_for: (d = new Date(), d.setDate(d.getDate() + 1), d.toISOString()), autoschedule: true, debug: true });
</script>
<script type="text/javascript">
window.customerguru=window.customerguru||[],customerguru.load=function(t,e){window.customerguru.client_token=t,window.customerguru.config=e=e||{};var r=e.forceSSL||"https:"===document.location.protocol,u=document.createElement("script");u.type="text/javascript",u.async=!0,u.src=(r?"https:":"http:")+"//cdn.customer.guru/embed/v1.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(u,o);for(var c=function(){return function(){customerguru.push(Array.prototype.slice.call(arguments,0))}},n=["schedule"],s=0;s<n.length;s++)customerguru[n[s]]=c(n[s])};
customerguru.load("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY", { scheduled_for: (d = new Date(), d.setDate(d.getDate() + 7), d.toISOString()), autoschedule: true, debug: true });
</script>
autoschedule: true option is present, every time a form is submitted on this page, our JavaScript client will automatically send the information from the email field together with all other visible fields (excluding passwords and credit cards) to Customer.guru and schedule an e-mail survey.
If you don't want to rely on the autoschedule feature, you can always schedule your surveys explicitly.
When you want to schedule a survey (e.g. in form submit event handler), just call the schedule method.
customerguru.schedule(
email,
properties,
callback,
scheduled_for,
language
)
Note that only email is required, all other parameters are optional.
Example:
customerguru.schedule(
"[email protected]",
{ product: 't-shirt', order_count: '5', total_amount_paid: '125.12', first_order_created_at: '2015-12-13' },
function(status) { console.log('Customer.guru API responded with:', status) },
(d = new Date(), d.setDate(d.getDate() + 7), d.toISOString()), // send survey in 7 days
'fr' // survey this customer in French
)
customerguru.load(client_token, preferences)
Initializes the Customer.guru object. Needs to be run before any schedule calls.
Your client-side identifier you can find in the API keys section.
If set to false the JavaScript client prints verbose console.log messages even for successful API calls. Use this option in development.
Default value: false
When set to true the JavaScript client will automatically schedule surveys for all submitted forms that include a field with a valid e-mail.
All other visible form fields (excluding type="hidden" and type="password", including only fields with name attribute)
are submitted along with the e-mail as customer properties.
If you also want to auto-submit fields that would be excluded otherwise, include customerguru-submit in their className.
Default value: false
Date in iso8601 (e.g. 2016-09-10T18:28:44Z) or now
Default value: now
Language of the survey. Value needs to be one of en, sk, de, it, ru, es, fr, cs, pl, hu, el, he, hr, pt-PT
Default value: null. Language configured in survey settings is used.
If set to false the API does not actually schedule the emails. Use this option in development.
Default value: false
Timeout in milliseconds for schedule requests.
Default value: 1000
customerguru.schedule(email, properties, callback, scheduled_for, language)
Customer e-mail address
Customer meta information that is later useful for customer segmentation.
Example:
{ product: 't-shirt', order_count: '5', total_amount_paid: '125.12', first_order_created_at: '2015-12-13' }
Function to be called after every API request. Response status is included as a parameter.
Date in iso8601 (e.g. 2016-09-10T18:28:44Z) or now
This has precedence over scheduled_for used in the .load() call
Language of the survey. Value needs to be one of en, sk, de, it, ru, es, fr, cs, pl, hu, el, he, hr, pt-PT
This has precedence over language used in the .load() call