Setting Cause Tracking via 3rd Party Source

Set a nonprofit from a 3rd party source outside of the ShoppingGives Cause Select Modal

This guide helps you set a nonprofit from a 3rd party source outside of the ShoppingGives Cause Select Modal. Through these steps, you will be able to integrate a selected nonprofit into the ShoppingGives widget.


Who should read this:

The webmaster or developer with source code level access to the e-commerce website.


Integrate with ShoppingGives Storefront Widgets Integration, and requires widgets to be set up prior to setting tracking from your application or user.

Basic Instructions

Paste the following function into your site where needed and invoke it when needed. See usage on how to supply values to the function. Please make sure that all EINs supplied are in good standing with Pub78 and are true 501c3 or the donation will not be generated.


function setCause(ein, causeName, storeId) {
  let request = new XMLHttpRequest();
  request.onload = () => {
      if(request.status >= 200 && request.status < 400) {
          let json = JSON.stringify({eventName:"causeUpdated", targetWidgetId:"*", payload:{causeId:ein,causeName:causeName,causeType:2}});
          window.postMessage(json, '*');
  let trackingId = atob(sessionStorage.getItem('sg.sid-' + storeId));'PUT', '' + trackingId + '/set-cause', true);
  request.setRequestHeader('Content-Type', 'application/json');
  let body = JSON.stringify({causeId:ein, causeName: causeName});

Function Usage

setCause(200352967, 'Mountain View School Parent Teacher Organization Inc.', '32112356-fca3-4b2a-bbbe-e624c3245671');

Expected Results:

All widgets on the page should update with the cause that was provided from the Function.