SaaSquatch Help Center

An installation walkthrough for the Referral SaaSquatch Segment Integration, explanations of common usage cases, and code examples.

Using the Segment Integration

This quickstart guide will walk you through setting up a referral program by making use the Referral SaaSquatch integration with Segment.io.

The Segment integration with Referral SaaSquatch allows you to replace the functionality of the Referral SaaSquatch squatch.js library with that of the Segment Analytics Library's Identify method. This quickstart guide includes code examples for common use-cases for the segment integration.

The use of Segment in your referral program can be extended beyond what is covered in this Quickstart Guide by simply substituting the SaaSquatch squatch.js library for the Segment Analytics Library's Identify method where applicable. Our Guides portal also contains examples for a range of business models and reward types.

Further details can be found in our Segment Integration Reference

Configuring Segment

Select the Workspace and Source

  1. Select the Segment Workspace that you would like to add the SaaSquatch integration to:

    Segment Workspace Select - Highlighted

  2. Select the source that you would like add the SaaSquatch integration to:

    Segment Source Select - Highlighted

Enable SaaSquatch Integration

Search for "SaaSquatch", select the item, and click the green "Enable Integration" button:

Segment SaaSquatch Select - Highlighted

Configure Tenant

Go the settings page for the integration and insert the tenant alias you would like to use.

Note: Make sure to change this value to your live tenant alias when you have completed testing and your product goes live.

Segment SaaSquatch Settings - Highlighted

Segment Code in Page

Please refer to Segment's setup guide for how to integrate their Analytics.js Library into your product.

Step 2 of that setup guide includes details about using the analytics.identify method.

The following is a basic example of using analytics.js:


<script type = "text/javascript">
  ! function() {
    var analytics = window.analytics = window.analytics || [];
    if (!analytics.initialize)
      if (analytics.invoked) window.console && console.error && console.error("Segment snippet included twice.");
      else {
        analytics.invoked = !0;
        analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "page", "once", "off", "on"];
        analytics.factory = function(t) {
          return function() {
            var e = Array.prototype.slice.call(arguments);
            e.unshift(t);
            analytics.push(e);
            return analytics
          }
        };
        for (var t = 0; t < analytics.methods.length; t++) {
          var e = analytics.methods[t];
          analytics[e] = analytics.factory(e)
        }
        analytics.load = function(t) {
          var e = document.createElement("script");
          e.type = "text/javascript";
          e.async = !0;
          e.src = ("https:" === document.location.protocol ? "https://" : "http://") + "cdn.segment.com/analytics.js/v1/" + t + "/analytics.min.js";
          var n = document.getElementsByTagName("script")[0];
          n.parentNode.insertBefore(e, n)
        };
        analytics.SNIPPET_VERSION = "3.1.0";
        analytics.load("YOUR_WRITE_KEY");
        analytics.page()

        analytics.identify('f4ca124298', {
          name: 'Michael Bolton',
          email: 'mbolton@initech.com'
        });

      }
  }(); </script>

The subsequent parts of this Quickstart Guide assume the main segment code has been correctly configured in your page. The examples below will only cover the changes to the identify method which relate to the Referral SaaSquatch integration.

Display the Referral Widget

Identify the users to Referral SaaSquatch and enable them to share their unique sharelink to their network of friends through email, Facebook, or Twitter.

analytics.identify( "abc_172", {
    accountId: "abc_172",
    email: "test2@example.com",
    firstName: "test2",
    lastName: "test2",
    paymentProviderId: 'null'
},{
    integrations: {
        SaaSquatch: {
            checksum: null
        }
    }
});

Embedded Mode

By default the referral widget is displayed in Popup mode. The referral widget can also be displayed in embedded mode by including the mode parameter set to EMBED:

analytics.identify( "abc_170", {
    accountId: "abc_170",
    email: "test@example.com",
    firstName: "test",
    lastName: "test",
    mode:"EMBED",
    paymentProviderId: 'null'
},{
    integrations: {
        SaaSquatch: {
            checksum: null
        }
    }
});

Track Signups

The following script will identify a newly registered user to SaaSquatch. By loading the script in NOCONTENT mode it is being used for purely tracking purposes and will not load a widget.

The script will automatically look for a referral cookie in the referred user's browser and make the referral connection.

analytics.identify( "abc_170", {
    accountId: "abc_170",
    email: "test@example.com",
    firstName: "test",
    lastName: "test",
    mode:"NOCONTENT",
    paymentProviderId: 'null'
},{
    integrations: {
        SaaSquatch: {
            checksum: null
        }
    }
});

Convert Referrals

API Programs

For API programs converting a referral is accomplished by including the accountStatus parameter set to PAID:

analytics.identify( "abc_172", {
    accountId: "abc_172",
    email: "test2@example.com",
    firstName: "test2",
    lastName: "test2",
    accountStatus: 'PAID',
    paymentProviderId: 'null'
},{
    integrations: {
        SaaSquatch: {
            checksum: "{{Calculated_Checksum}}"
        }
    }
});

Payment Provider Integrations

For Programs configured for one of our Payment Provider Integrations (e.g. Stripe or Recurly) the conversion is accomplished in the Payment Provider itself. Simply include the user's ID from the payment provider as paymentProviderId so that our system can track when a conversion happens.

Further details about Payment Provider Integrations can be found in the guides section of our docs.

analytics.identify( "abc_170", {
    accountId: "abc_170",
    email: "test@example.com",
    firstName: "test",
    lastName: "test",
    paymentProviderId: "cus_8yKs12342nsNl"
},{
    integrations: {
        SaaSquatch: {
            checksum: "{{Calculated_Checksum}}"
        }
    }
});

Note:

  • Payment Provider programs have slightly different Signed Request requirements than API programs. Please refer to our Signed Requests page for further details.
  • Signed Requests using JWT are not currently supported using the Segment integration.

Additional Resources

The Reference doc for our Segment Integration and squatch.js library provide further details about how to go about setting up this integration.

Segment provides an overview of, and the Github code for, their Integration with Referral SaaSquatch.