Web SDK FAQs

A few short FAQs about the Apptentive SDK to help with integration and use.

Q: What impact on my website performance should I expect due to Apptentive’s Web SDK?

The SDK is loaded asynchronously, non-blocking, and should not interfere with the loading time of the page in a meaningful way. Size wise, it is approximately 8kb in size when minified and gzipped, with the average request being under 500 bytes.

Q: What are examples of events that I could engage? How do I create an event?

Events should occur when your customer makes a meaningful action or somewhere you might want to interact with them. All Events are created with ApptentiveSDK.engage(). Interactions are triggered using Events, so the more Events you have placed the more places you have to trigger Interactions.

Adding Items to a Cart

ApptentiveSDK.engage('added-item', { sku: 'B00TSUGXKE', price: 39.99 });

Playing a Song or Video

ApptentiveSDK.engage('played-song', { artist: 'Olafur Arnalds', track: 'Say My Name (Feat. Arnor Dan)' });

Scroll Depth

Using the Waypoints JavaScript library.

var waypoint = new Waypoint({
  element: document.getElementById('bottom-of-page'),
  handler: function(direction) {
    ApptentiveSDK.engage('hit-bottom');
  }
});

After Exactly n Seconds on a Page

var seconds = 5;
setTimeout(function(){
  ApptentiveSDK.engage('waited-5-seconds');
}, seconds * 1000);

Read an Article

This will track both time spent on page and trigger when the user scrolls to a certain element on the page using Waypoints.

var time_on_page_start = Date.now();
var waypoint = new Waypoint({
  element: document.getElementById('bottom-of-article'),
  handler: function(direction) {
    var time_on_page_end = Date.now();
    ApptentiveSDK.engage('read-article', {
      article: 'infographic-holiday-shopping-retail-mobile-apps/',
      duration: time_on_page_end - time_on_page_start
    });
  }
});

URL / Query Parameter Triggers

If you wanted to, for example, send a web survey in an email such that it takes customers to a particular page on your website and shows them a Survey, however, customers not coming from the email should not see the Survey.

Email:

<a href="https://apptentive.com/blog/?apptentive-event=take-email-survey">Take our Survey!</a>

Webpage:

function getParameter(name) {
  name = name.replace(/[\[\]]/g, "\\$&");
  var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(window.location.href);
  if (!results) return null;
  if (!results[2]) return '';
  return decodeURIComponent(results[2].replace(/\+/g, " "));
}

var event = getParameter('apptentive-event');
if (event) ApptentiveSDK.engage(event);

Q: Are partial responses captured?

Not at this time.

Q: Are there scenarios when same survey could be displayed multiple times to the same customer even if I have disabled “Allow multiple responses from the same person”?

Yes, if a user switched browsers or clears the localStorage data their “history” resets and they will be treated as if they have never been to the site before.

Updated on March 27, 2017

Was this article helpful?

Related Articles