Apptentive for Web FAQs

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

Q: What impact on my website performance should I expect due to Apptentive for Web’s 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, clears the localStorage data, or accesses your site from a different device, their “history” resets and they will be treated as if they have never been to the site before.

For this reason, we recommend using Events that customers hit regularly in your targeting. For example, you may want to show a Survey to customers that triggered a specific event 120 days ago. However, it is likely that some portion of those customers have cleared their localStorage since then, and thus are ineligible to see that Survey. Instead, consider showing a Survey to customers after they have completed a certain action and are at a point when you will not interrupt them.

Q: Is the Web SDK compatible with modern web apps (Single Page Apps)?

Yes, the Web SDK is Javascript and should be compatible with all modern apps. You can trigger using custom Events. Because of its Javascript nature, browser compatibility is more important. The Web SDK should work for most modern browsers. For IE specifically, only IE10+ compatibility is supported.

Q: Can I wrap the code for the SDK?

We do not support wrapping the code. It can inadvertently cause problems with initializing the SDK and can greatly impact how many customers you are able to engage with Apptentive. 

Updated on June 11, 2020

Was this article helpful?

Related Articles