# Gainsight PX Cloud Mode Integration

<p>After you have successfully <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/gainsight-px/setup-guide/" >instrumented</a> Gainsight PX as a destination in RudderStack, follow this guide to correctly send your events to Gainsight PX in <a href="https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/#cloud-mode" >cloud mode</a>.</p>
<p>Find the open source transformer code for this destination in the <a href="https://github.com/rudderlabs/rudder-transformer/tree/main/src/v0/destinations/gainsight_px" >GitHub repository</a>.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">RudderStack requires the <code>userId</code> field for the <code>identify</code>, <code>group</code>, and <code>track</code> calls. If <code>userId</code> is absent, it uses <code>anonymousId</code> instead.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="identify">Identify</h2><p>RudderStack creates a <code>User</code> object in Gainsight PX when you make an <a href="https://www.rudderstack.com/docs/event-spec/standard-events/identify/" ><code>identify</code></a> call. It maps the <code>userId</code> from the event to Gainsight&rsquo;s <code>identifyId</code> (unique identifier for the <code>User</code> object). If <code>userId</code> is absent, RudderStack uses <code>anonymousId</code> instead.</p>
<p>RudderStack supports all default attributes for the <code>User</code> object. You can map the custom atrributes in the RudderStack event to the Gainsight PX custom attributes using <strong>User Attribute Mapping</strong> <a href="" >dashboard setting</a>:</p>

<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text">RudderStack drops any undefined custom attributes from the event and sends the rest of the attributes to Gainsight PX.</div>
  </div>
</blockquote>

<figure class="image--main "  >
    <a 
         href="/docs/images/event-stream-destinations/gainsightpx-identify-mapping.webp"
        
        >
        <img src="/docs/images/event-stream-destinations/gainsightpx-identify-mapping.webp" 
         
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>A sample <code>identify</code> call is shown:</p>
<div class="rs-code">
  <div class="rs-code__head">javascript<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-javascript" data-lang="javascript">rudderanalytics.identify(&#34;1hKOmRA4el9Z&#34;, {
  email: &#34;alex@example.com&#34;,
  name: &#34;Alex Keener&#34;,
  gender: &#34;Male&#34;,
  countryName: &#34;USA&#34;,
  countryCode: &#34;US&#34;,
  city: &#34;New Orleans&#34;,
  score: 100,
  hobbyCustomField: &#34;Painting&#34;,
  title: &#34;Doctor&#34;,
})</code></pre></div>
</div>
<p>In the above example, <code>hobbyCustomField</code> is a custom field. You need to provide the mapping for <code>hobbyCustomField</code> to the corresponding custom attribute <code>hobby</code> <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/gainsight-px/setup-guide/#create-custom-attributes" >created in Gainsight PX</a>. If you do not provide this mapping, RudderStack drops the <code>hobbyCustomField</code> attribute and sends the other attributes to Gainsight PX.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="track">Track</h2><p>RudderStack uses the Gainsight PX&rsquo;s <a href="https://support.gainsight.com/PX/API_for_Developers/02Usage_of_Different_APIs/Use_Custom_Event_API" >Custom Event API</a> for sending the <a href="https://www.rudderstack.com/docs/event-spec/standard-events/track/" ><code>track</code></a> events.</p>
<p>A sample <code>track</code> call is shown:</p>
<div class="rs-code">
  <div class="rs-code__head">javascript<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-javascript" data-lang="javascript">rudderanalytics.track(&#34;User Tracked&#34;, {
  description: &#34;Sample user tracking event&#34;,
  status: &#34;Demo&#34;,
})</code></pre></div>
</div>
<p>RudderStack maps the event name to the <code>eventName</code> field in Gainsight PX.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="specify-global-context-metadata">Specify global context metadata</h3><p>You can provide the <a href="https://support.gainsight.com/PX/Engagements/02Engagement_Configuration/Use_Global_Context" >Global Context</a> metadata by specifying the <code>globalContext</code> object in the <code>track</code> event as shown:</p>
<div class="rs-code">
  <div class="rs-code__head">javascript<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-javascript" data-lang="javascript">rudderanalytics.track(&#34;User Tracked&#34;, {
  description: &#34;Sample user tracking event&#34;,
  status: &#34;Demo&#34;,
  globalContext: {
    projectId: &#34;p-123&#34;,
  },
})</code></pre></div>
</div>
<p>Alternatively, you can set the global context for the <code>track</code> events by specifying the key-value pairs under the <strong>Global Context Mapping</strong> <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/gainsight-px/setup-guide/#connection-settings" >dashboard setting</a>, as shown:</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/event-stream-destinations/gainsight-px-global-context-mapping.webp"
        
        >
        <img src="/docs/images/event-stream-destinations/gainsight-px-global-context-mapping.webp" 
         
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">RudderStack gives higher precedence to the global context metadata specified in the event over the key-value pairs specified in the <strong>Global Context Mapping</strong> setting.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="group">Group</h2><p>RudderStack associates the user with an account in Gainsight PX when you send a <a href="https://www.rudderstack.com/docs/event-spec/standard-events/group/" ><code>group</code></a> event. It automatically maps the <code>groupId</code> to the <code>accountId</code> in Gainsight PX.</p>
<p>RudderStack supports all the default fields for <code>Account</code> object. In addition, you can map the custom RudderStack event attributes to Gainsight custom attributes in the <strong>Account Attribute Mapping</strong> <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/gainsight-px/setup-guide/#connection-settings" >dashboard setting</a>:</p>

<figure class="image--main "  >
    <a 
         href="/docs/images/event-stream-destinations/gainsightpx-group-mapping.webp"
        
        >
        <img src="/docs/images/event-stream-destinations/gainsightpx-group-mapping.webp" 
         
         
         
        decoding="async" loading="lazy" class="img-shortcode"/>
    </a>
    
</figure>

<p>A sample <code>group</code> call is shown:</p>
<div class="rs-code">
  <div class="rs-code__head">javascript<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-javascript" data-lang="javascript">rudderanalytics.group(&#34;group18&#34;, {
  name: &#34;Sample Group&#34;,
  industry: &#34;Online Streaming&#34;,
  numberOfEmployees: 10000,
  website: &#34;www.example-group.com&#34;,
  cultureCustomField: &#34;customfield01&#34;,
})</code></pre></div>
</div>
<p>In the above example, <code>cultureCustomField</code> is a custom field. You need to provide the mapping for <code>cultureCustomField</code> to the corresponding custom attribute <code>customfield01</code> <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/gainsight-px/setup-guide/#create-custom-attributes" >created in Gainsight PX</a>. If you do not provide this mapping, RudderStack drops the <code>cultureCustomField</code> attribute and sends the other attributes to Gainsight PX.</p>
<p>To update the group details with fewer API calls to Gainsight PX, make sure to set <code>limitAPIForGroup</code> to <code>true</code> in the event&rsquo;s <code>context</code>, as shown:</p>
<div class="rs-code">
  <div class="rs-code__head">javascript<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-javascript" data-lang="javascript">rudderanalytics.group(
  &#39;group18&#39;, {
    name: &#39;New Group Name&#39;,
    industry: &#39;Online Streaming&#39;,
    numberOfEmployees: 5000,
    website: &#39;www.new-group.com&#39;,
    cultureCustomField: &#39;customfield01&#39;,
  }, {
    integrations: {
      All: true,
      GAINSIGHT_PX: {
        limitAPIForGroup: true
      }
    }
  },
);</code></pre></div>
</div>
<p>Note that the if the <code>groupId</code> is invalid, then RudderStack creates a new group in Gainsight PX with the provided ID.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="location-attribute-mapping">Location attribute mapping</h2><p>RudderStack maps the below event properties to the corresponding location properties of the Gainsight PX <code>User</code> and <code>Account</code> objects:</p>
<table>
  <thead>
      <tr>
          <th>RudderStack property</th>
          <th>Gainsight PX property</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>countryName</code></td>
          <td><code>location.countryName</code></td>
      </tr>
      <tr>
          <td><code>countryCode</code></td>
          <td><code>location.countryCode</code></td>
      </tr>
      <tr>
          <td><code>stateName</code></td>
          <td><code>location.stateName</code></td>
      </tr>
      <tr>
          <td><code>stateCode</code></td>
          <td><code>location.stateCode</code></td>
      </tr>
      <tr>
          <td><code>city</code></td>
          <td><code>location.city</code></td>
      </tr>
      <tr>
          <td><code>street</code></td>
          <td><code>location.street</code></td>
      </tr>
      <tr>
          <td><code>postalCode</code></td>
          <td><code>location.postalCode</code></td>
      </tr>
      <tr>
          <td><code>continent</code></td>
          <td><code>location.continent</code></td>
      </tr>
      <tr>
          <td><code>regionName</code></td>
          <td><code>location.regionName</code></td>
      </tr>
      <tr>
          <td><code>timeZone</code></td>
          <td><code>location.timeZone</code></td>
      </tr>
      <tr>
          <td><code>latitude</code></td>
          <td><code>location.coordinates.latitude</code></td>
      </tr>
      <tr>
          <td><code>longitude</code></td>
          <td><code>location.coordinates.longitude</code></td>
      </tr>
  </tbody>
</table>
<br />
