Client Code (Web SDK) - Customer Passed Parameters

Customer Passed Parameters (CPPs) Overview

Customer Passed Parameters (CPPs) are used to send data points available on the client’s website along with the survey response. The value of these parameters can be used for segmenting the client’s respondent data. The client may send as many parameters as desired using the methods described in this topic. ForeSee suggests limiting CPPs to meaningful data intended for specific reporting for these reasons:

  1. Adding CPPs may increase cookie size.
  2. Internet Explorer limits the number of characters in a URL string to 2084 including the URL to the survey. If additional CPPs cause the URL to exceed this limit, data may not be passed with the survey and, therefore, unavailable in the respondent data.

Setting CPPs

Setting a CPP with the CPP API

The API in the Setting a CPP code sample below can be used to manually set a CPP on the client’s site. This line can be duplicated as many times as desired, taking care that it’s placed below the Client Code snippet (versions 18x and above), or the call to foresee-trigger.js (versions below 18x) on the page.

In the following example, ‘name’ is the name of the CPP to be passed and viable in the portal. The value can be either a static hard-coded value, or a dynamic variable which can be customized to pass whatever data is preferred.

<script type="text/javascript">
    // Instructions: please embed this snippet directly into every page in your website template.
    // For optimal performance, this must be embedded directly into the template, not referenced as an external file.
    // DO NOT MODIFY BELOW THIS LINE *****************************************
    ;(function (g) {
      var d = document, am = d.createElement('script'), h = d.head || d.getElementsByTagName("head")[0], fsr = 'fsReady',
        aex = {
          "src": "[//gateway.foresee.com/sites/[your sitekey]/staging/gateway.min.js]",
          "type": "text/javascript",
          "async": "true",
          "data-vendor": "fs",
          "data-role": "gateway"
        };
      for (var attr in aex){am.setAttribute(attr, aex[attr]);}h.appendChild(am);g[fsr] = function () {var aT = '__' + fsr + '_stk__';g[aT] = g[aT] || [];g[aT].push(arguments);};
    })(window);
    // DO NOT MODIFY ABOVE THIS LINE *****************************************

// When adding the CPP API this should appear BELOW the ForeSee embed snippet
fsReady(function() {
     FSR.CPPS.set('name','value');
});
</script>

Setting CPPs from Client Code Configurations

The following capabilities must be added by a member of the Implementation Team. You can request these changes from your ForeSee Client Contact.

  • Pass the value of a JavaScript variable – Using JavaScript variable name/value.
  • Pass the value of a cookie – Using cookie name.
  • Create a CPP using a URL – e.g., if the URL string contains “xyz” set a value of “Y.”
  • Create a CPP using a URL query string parameter – e.g., Find “paramname=” in the URL and grab the value.

Reading CPP values

Reading CPPs from the API function (Client Code 19.3.3 and above)

Use the FSR.CPPS.all function to read the values of the CPPs that have been set. The CPP values can be either read all at once, selectively. Here is a code sample.

fsReady(function() {
	FSR.CPPS.all(function (r){
		console.log("List of CPPS: ", r);
	});
	FSR.CPPS.get('my_cpp_name', function(val) {
		console.log("CPP value: ", val);
	});
});

Reading CPPs with the Survey URL

When a survey questionnaire appears, find the CPP parameters in the URL string:

http://survey.foreseeresults.com/survey/display?sid=browse-clientsite.com-en&cid=gcdwU50NZxxRxwJI1IEw%3D%3D&pattern=http%3A%2F%2Fwww.clientsite.com%2F&a=1293032648063_751683&b=38790979455466765205&c=86400000&version=5.0.0&cpp[orderDate]=12%2F22%2F2010&cpp[TLSessionID]=4EEBFE540DE2100D7A51B7D51C444613&cpp[browser]=Firefox%203.6&cpp[os]=Windows&cpp[pv]=2&cpp[url]=http%3A%2F%2Fwww.clientsite.com%2F&cpp[ref_url]=&cpp[locale]=en&cpp[site]=clientsite.com&cpp[section]=&cpp[referrer]=&cpp[terms]=&cpp[sessionid]=1293032648063_751683&cpp[replay_id]=&cpp[flash]=10

Reading CPPs from the fsr.s cookie (Client Code 19.0.x and below)

Open the fsr.s cookie to view the parameters inside the “cp” attribute. CPPs are listed by name then current value to be passed.

"cp":{"ads":"none","icmpid":"none","cmpid":"none","icid":"none","cid":"none"},

Articles in this section:

  1. Default CPPs