Skip to content

trellisconnect/savvy-sdk-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 

Repository files navigation

Savvy Insurance SDK

Savvy allows users to quickly and easily find savings on their existing insurance.

Your website or mobile app can easily embed the "Savvy Widget" so that users can find these savings without ever navigating off your property.

Basic Usage

Implementing Savvy Widget is easy. Just copy-and-paste a few lines of code:

<script src="https://cdn.savvy.insure/sdk/v1.0/savvy.js"></script>
<button id="openSavvyBtn">Check My Policy for Savings</button>
<script>
  (function () {
    var handler = Savvy.configure({
      urlTrackingParams: "REPLACE-THIS-WITH-STRING-FROM-SAVVY",
      savvyClientId: "YOUR-SAVVY-CLIENT-ID",
    });
    document.getElementById("openSavvyBtn").onclick = handler.open;
  })();
</script>

Attribution & Tracking

In order to get credit for your usage, you MUST set urlTrackingParams in Savvy.configure to the value assigned by your Savvy affiliate success contact (i.e. replace the 'REPLACE-THIS-WITH-STRING-FROM-SAVVY' placeholder).

Examples:

  • Minimum requirement: '?utm_source=affiliatecode' (where affiliatecode will be provided to you by your Savvy affiliate success contact)
  • Minimum requirement for incentivized traffic: '?utm_source=affiliatecode&utm_medium=incentive'
  • Adding your user_id: '?utm_source=affiliatecode&external_partner_id=123456' (where 123456 is your internal user_id)
    • This can be useful so that Savvy can send back per-user performance reporting that you can join Savvy's funnel data to your internal data
    • Savvy expects external_partner_id to represent a unique human end user
  • Adding your click_id: '?utm_source=affiliatecode&txn=98765' (where 98765 is your internal click_id, transaction_id, etc.)
  • Adding campaign information: '?utm_source=affiliatecode&external_partner_id=123456&utm_campaign=sidebar' (where "sidebar" is the placement name on your site/app)

Note that you are not limited to just these parameters. See Savvy URL Tracking Parameters Documentation for more information.

Advanced Usage

Anchor element call-to-action (CTA)

You can use an <a> element instead of a <button>:

<script src="https://cdn.savvy.insure/sdk/v1.0/savvy.js"></script>
<a href="#" id="openSavvyBtn">Check My Policy for Savings</a>
<script>
  (function () {
    var handler = Savvy.configure({
      urlTrackingParams: "REPLACE-THIS-WITH-STRING-FROM-SAVVY",
      savvyClientId: "YOUR-SAVVY-CLIENT-ID",
    });
    function handleClick(event) {
      event.preventDefault();
      handler.open();
    }
    document.getElementById("openSavvyBtn").onclick = handleClick;
  })();
</script>

Callbacks

Savvy Widget supports a number of Javascript callbacks that you can use for analytic purposes and to personalize the user experience around the progress made in the Savvy Widget.

<script src="https://cdn.savvy.insure/sdk/v1.0/savvy.js"></script>
<button id="openSavvyBtn">Check My Policy for Savings</button>
<script>
  (function () {
    var handler = Savvy.configure({
      // REQURIED: Use the tracking/attribution params provided by your contact at Savvy.
      // See https://docs.google.com/document/d/1GF1yxu8BMfpK30EJ4AJZ3lhVuX_6Ae0Cdi2LPXAiAqY
      // for more information.
      urlTrackingParams: "?utm_source=YOUR_ID&utm_medium=incentive",

      // REQUIRED: Your Savvy Client ID. This allows you access to the Savvy API functionality in the sdk.
      savvyClientId: "YOUR-SAVVY-CLIENT-ID",

      // OPTIONAL: Set the experience to 'connect' if you want to prevent Savvy SDK from displaying
      // results (e.g. if you intend to use Savvy API to render the results natively).
      // Otherwise, leave undefined.
      experience: undefined,

      // OPTIONAL: If the Savvy Widget is going to be embedded in a native web view, set isWebView: true
      isWebView: false,

      // OPTIONAL: onClose(error, metadata)
      // Called when the user closes the modal dialog.
      // - metadata
      //   - metadata.accountReferenceId - Account reference ID to use for searching Savvy.
      //                                   Currently set equal to Trellis Connection ID when
      //                                   Trellis Client ID is provided.
      //                                   May not be present if our servers could not be reached.
      onClose: handleClose,

      // OPTIONAL: onEvent(eventName, metadata)
      // Called when certain events happen. Supported event names:
      // - OPEN
      //     - The user has opened the widget.
      // - SELECT_ISSUER
      //     - The user has selected their insurance company.
      // - PROVIDE_CONSENT
      //     - The user has consented to Savvy's searching for offers.
      // - APPLICATION_COMPLETE
      //     - Enough data has been received that Savvy can get personalized offers.
      // - LOAD_OFFERS
      //     - The user has finished waiting for offers.
      // - CLICK_OFFER
      //     - The user clicked on a specific offer.
      // - TRANSITION_VIEW
      //     - When the Widget transitions between views.
      // - CLOSE
      //     - The flow has been exited. Also calls `onClose` callback.
      // - ERROR
      //     - If an error happens during the flow.
      onEvent: handleSavvyEvent,
    });
    document.getElementById("openSavvyBtn").onclick = handler.open;
  })();
</script>

destroy() function

The destroy function allows you to destroy the Savvy handler instance, properly removing any DOM artifacts that were created by it. This function will fail if called when Savvy Widget is open.

<script>
  // Create the Savvy handler
  var handler = Savvy.configure({
    urlTrackingParams: "REPLACE-THIS-WITH-STRING-FROM-SAVVY",
    savvyClientId: "YOUR-SAVVY-CLIENT-ID",
  });

  // Destroy handler
  handler.destroy();
</script>

Headless Action - Get Account Reference ID

After configuring the Savvy Widget, you can obtain an Account Reference ID without requiring the user to interact with the Savvy Widget by using this headless action.

IMPORTANT: Avoid calling this headless action after opening the Savvy Widget! You may get the wrong Account Reference ID!

<script>
  var handler = Savvy.configure({
    // ... existing configuration including `urlTrackingParams` and `savvyClientId`

    // See the Callbacks section above for more details about onClose.
    onClose: handleOnClose,
  });

  // This can be called when it makes the most sense in the user's journey.
  // It triggers the onClose callback with the Account Reference ID for the user.
  try {
    handler.headless("GET_ACCOUNT_REFERENCE");
  } catch (error) {
    // Headless actions Errors
    // - Unsupported action
    // - Savvy Widget isn't configured/ready
    // - Savvy Widget is currently open
  }
</script>

CHANGELOG

  • 2026-02-09
    • Deprecate linked documentation
  • 2020-12-16
    • Update basic usage demos
  • 2020-04-28
    • Update "onClose" handler to pass metadata that includes accountRefId.
  • 2020-02-13 – Initial draft

About

Savvy Insurance SDK Implementation Docs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors