---
title: "Segment Whatfix content using User Attributes and Google Sheets"
slug: "google-sheet-integration-with-user-attribute"
updated: 2025-08-20T07:31:58Z
published: 2025-08-20T07:31:58Z
canonical: "support.whatfix.com/google-sheet-integration-with-user-attribute"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.whatfix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Segment Whatfix content using User Attributes and Google Sheets

Whatfix enables you to use to segment content to show it to specific users using a Google Sheet integration. This method is useful when you want to display content to to a specific group of users.

[What is a User Attribute?](/studio/docs/google-sheet-integration-with-user-attribute#what-is-a-user-attribute)

[Use Cases](/studio/docs/google-sheet-integration-with-user-attribute#use-cases)

[Create a Google Sheet with User Data](/studio/docs/google-sheet-integration-with-user-attribute#create-a-google-sheet-with-user-data)

[Create a User Attribute](/studio/docs/google-sheet-integration-with-user-attribute#create-a-user-attribute)

[Create an Integration on the Dashboard](/studio/docs/google-sheet-integration-with-user-attribute#create-an-integration-on-the-whatfix-guidance-dashboard)

[Run the integration](/studio/docs/google-sheet-integration-with-user-attribute#run-the-google-sheet-integration)

[Use the User Attribute in Visibility Rules](/studio/docs/google-sheet-integration-with-user-attribute#use-the-user-attribute-in-visibility-rules)

  

#### **What is a User Attribute?**

Whatfix User Attributes enable you to fetch end-users' information such as role, signup date, department, and subscription plan, from your application and use them in Google Sheets for easy content segmentation and personalization.

For more information, see [User Attributes](/studio/docs/user-attributes).

#### **Use Cases**

- A department-based Training Task List that contains the weekly training materials and tasks for that appears only to new joinees. You can segment the Whatfix content with your team members' names.
- Pop-up embedded with the NPS survey to appear only to customers who haven’t yet filled out the survey. You can segment the content based on the email IDs.

> [!WARNING]
> Note:
> 
> - To modify user-related data in Google Sheets for content segmentation, you need to update the file manually and rerun the integration for the changes to take effect.
> - To avoid manual updates, [create Cohorts in Whatfix Product Analytics](/product-analytics/docs/create-a-cohort) and use them as Visibility Rules. Cohorts refresh automatically whenever a user meets the Cohort criteria (for example, joins a new country, performs an action in the application, or interacts with Whatfix content), they’re added to the Cohort and immediately see the relevant Whatfix content. For more information, see [Add Cohorts as Visibility Rules](/product-analytics/docs/add-cohorts-as-visibility-rules).

#### **Create a Google Sheet with User Data**

Use the following steps to create a Google Sheet with User Data (User Name and User Attribute):

> [!WARNING]
> Note:
> 
> The following example steps show how you can display content to a specific group of people in a department.

1. Create a Google Sheet with end-user specific information available on the application. Here’s an example: ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-AKYMCADF.png)

> [!NOTE]
> Info:
> 
> **Name** is the user information available in the application and `insalesdepartment` is the User Attribute. The User Attribute value is set to `Yes`. This means that when the value of the User Attribute is `Yes`; it fetches the team members' names and can be used to display content only to those who match the criteria.

1. Click **Share**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-Z2LO4OP3.png)

> [!WARNING]
> Note:
> 
> Whatfix must be granted the required access permissions to fetch data from the Google Sheet.

1. Select **Anyone with the link**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-KUTE5EDU.png)

1. Click **Done**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-S1RNKY3L.png)

#### Create a User Attribute

Use the following steps to create a user attribute to identify the users:

1. On the Whatfix Guidance dashboard, click **Settings**. ![ia_left_nav_settings](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left_nav_settings.png)
2. Click **App integrations**. ![ia_left%20nav_app%20integrations](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left%20nav_app%20integrations.png)

1. Under **My Integrations**, click **Attributes**. ![ia_db_integrations_attributes.png](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_db_integrations_attributes.png)

1. In the **User Attributes** tab, click **+ User Attribute**. ![ia_db_add_user_attribute.png](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_db_add_user_attribute.png)

1. Enter the **User Attribute Name** and select its **Variable Type**. For example, the **User Attribute Name** is `insalesdepartment` and the Variable Type is `string`.![Create_user_attribute](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/Create_user_attribute.png)

> [!NOTE]
> Info:
> 
> The following table lists the Variables Types and their description for a User Attribute:
> 
> | Variable Type | Description |
> | --- | --- |
> | String | A user attribute that is an exact match of a string value, such as a username. |
> | Encrypted_string | A String variable type, but the data is encrypted and stored in a database. |
> | Double | Specify a single number. For example, employee number. |
> | Boolean | A user attribute that has either true or false values. For example, whether or not the user had upgraded their plan or visited a specific section of the app. |
> | Timestamp | Select this option to specify a single date and time, such as the user’s birth date or signup date. |
> 
> 
> 
> **User Attribute Name:**The name cannot begin with numbers, include spaces, or contain special characters (except underscores).

1. Click **Save**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/save(5).png)

#### Create an Integration on the Whatfix Guidance Dashboard

Now, let’s create a Google Sheet Integration on the Whatfix Guidance Dashboard to fetch user data.

1. On the Whatfix Guidance dashboard, click **Settings**. ![ia_left_nav_settings](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left_nav_settings.png)
2. Click **App integrations**. ![ia_left%20nav_app%20integrations](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left%20nav_app%20integrations.png)

1. Click **Dashboard**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-N9OYV04A.png)

1. Click **Advanced Integration**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-5HUJY2DF.png)

1. Enter an **Integration Title**, **Integration Description**, and then select **Google Sheets** as the **Targeted Application**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-F08EW8SV.png)

1. In **STEP 1** of the integration, choose the **Step Type** as **JAVASCRIPT** from the drop-down menu, and then insert the following code in the **Script**field: ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/select_javascript(1).png)

```javascript
/*************** GoogleSheet Configuration ************/

// Replace spreadsheet id with Google spreadsheet id you have created.
attributes.google_spreadsheet_id = '1TIyldYVjw1a9RoD3jnTPizrKoxnc7bnLLaU9D4eM-pI';

// Replace sheet name
var google_sheet_name = encodeURI('Demo');

//Replace start cell number of your GSheet
var startCell = 'A2';

//Replace end column number of your GSheet
var endCell = 'B';

attributes.range = google_sheet_name + '!' + startCell + ':' + endCell;

/*************** Whatfix Configuration ************/

attributes.whatfixApiDomain = 'api.whatfix.com';

// Replace it with your Whatfix enterprise ID.
attributes.accountId = 'ent_id'; 

// Replace it with your username.
attributes.username = 'john_doe@whatfix.com'; 

 // Replace it with Whatfix api token.
attributes.apiKey = 'API_key';
```

> [!WARNING]
> Note:
> 
> You can find instructions in the code commented with a double slash character where you need to enter values specific to the user and organization creating the Google Sheet Integration. Perform the following changes in the above code:
> 
> 
> 
> - In the value `var startCell = 'A2'`, replace `A2` with the starting cell value of the data present in your Google Sheet (exclude the title).
> - In the value `var endCell = 'B’`, replace `B` with the ending cell value of the data present in your Google Sheet.
> - In the value `attributes.accountId = 'ent_id`', replace `ent_id` with the ENT ID of your account. To find the Enterprise ID of your account, see [How do I find my account ID and account name?](/studio/docs/how-do-i-find-my-ent-id)
> - In the value `attributes.apiKey = 'API_key'`, replace `API_key` with your API Token value: To generate an API Token, see [Generating the API Token](https://support.whatfix.com/docs/generatingtheapitoken?highlight=api).
> - In the value `attributes.username = 'john_doe@whatfix.com’`, replace `john_doe@whatfix.com` with your email id.

1. In the above code, enter the Google Sheet ID of your sheet as shown below for the value `attributes.google_spreadsheet_id`. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/google_sheet_id.png)

1. Enter the Name of the Google Sheet as the value for `attributes.range google_sheet_name = '';`. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/add_your_sheet_name.png)

1. Click the **+ icon**. In **STEP 2**of integration, choose the **Step Type** as **REQUEST**. In the **Connect App**section, select **Google Sheets**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/select_google_sheets.png)

1. Click **Add Connection** and [allow Whatfix permission to access Google Sheets](https://support.google.com/accounts/answer/14012355?hl=en). ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-M9ONVDR6.png)

1. Select a connection; denoted by the time and date that you added the connection. You can choose to enter a **Description**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-Y5ICXQ1G.png)

1. In the URL section, select **GET** from the drop-down menu and insert the following URL. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/GET.png)

```plaintext
https://sheets.googleapis.com/v4/spreadsheets/${attributes.google_spreadsheet_id}/values/${attributes.range}
```

1. Click the **+ icon**. In **STEP 3** of integration, choose the **Step Type** as **JAVASCRIPT** and enter your JavaScript code in the **Script** field. Here’s an example: ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/script(1).png)

```javascript
var endUsers = [];

if (input.values && input.values != null && input.values.length > 0) {
  // Form end user objects
  for (i = 0; i < input.values.length; i++) {
    if (input.values[i][0] && input.values[i][0] !== '') {
      // Make sure 'IsSMComplete' user attribute is already created.
      var eu = {
        'id': input.values[i][0],
        'custom': {
           'user_attribute': input.values[i][1]
        }
      };
      endUsers.push(eu);
    } else {
      console.log(
        'INFO: Invalid end user ID. Skipping this row data of sheet.'
      );
    }
  }
} else if (!(input.values) && input.range) {
  console.log(
    'ERROR: No data found in provided google sheet. Terminating integration run...'
  );
  sys.exit();
} else {
  console.log('SUCCESS: All end users created/updated successfully in Whatfix.');
  sys.exit();
}

/**************** CREATING/UPDATING END USERS IN CHUCK OF SIZE=2000 USERS *************************/

if (endUsers.length <= 0) {
  console.log('ERROR: INVALID_GOOGELSHEET - No valid end user data found.');
  sys.exit();
} else {
  var start = 0;
  var end = 2000;
  var offset = 2000;
  var links = [];
  var url = 'https://' + attributes.whatfixApiDomain + '/v1/accounts/' + attributes.accountId + '/endUsers';
  var reqHeader = {
    'x-whatfix-integration-key': attributes.apiKey,
    'x-whatfix-user': attributes.username,
    'Content-Type': 'application/json'
  };

  while (start <= endUsers.length) {
    var reqBody = endUsers.slice(start, end);
    var link = {
      method: 'PUT',
      URL: url,
      headers: reqHeader,
      body: reqBody
    };
    links.push(link);
    start += offset;
    end += offset;
  }
  output.nextLinks = links;
}
```

1. Click **Save**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/save(5).png)

#### Run the Google Sheet Integration

Use the following steps to run the integration:

1. On the Whatfix Guidance dashboard, click **Settings**. ![ia_left_nav_settings](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left_nav_settings.png)
2. Click **App integrations**. ![ia_left%20nav_app%20integrations](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/ia_left%20nav_app%20integrations.png)

1. Click the **more** icon for the Integration you have added. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-G415HEM4.png)

1. Click **Run now**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-DX0J5D0K.png)

> [!NOTE]
> Info:
> 
> For more information, see [Scheduling an Integration](/studio/docs/scheduling-an-integration).

#### Use the User Attribute in Visibility Rules

Use the following steps to add the user attribute as a Visibility rule to the widget you want to segment:

Note:

If you see the following UI, you have the New Visibility Rules enabled for the account. For more information, see [Understand New Visibility Rules](https://support.whatfix.com/docs/understand-visibility-rules-20). ![Visibility Rules 2.0 screenshot](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/vr2_main%20page.png)

1. Edit the widget that you want to show only to the user part of the Sales department. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-EXB27CQY.png)

1. In the **Visibility** tab, select **User Attribute**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-BHTG8QQX.png)

1. Select the User Attribute you have created. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-3DF4XW3A.png)

1. Select the operator value `Equals` and enter the value `Yes`. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-214PZRXD.png)

1. Configure the other Visibility rules as required, and then click **Save**. ![](https://cdn.document360.io/a268766e-d74d-4619-9613-e2472f809ffb/Images/Documentation/image-JXYN8H35.png)

> [!WARNING]
> Note:
> 
> Once you have saved the widget, [preview the changes using the Preview extension](/studio/docs/preview-task-list), and then [publish the widget to Production](/studio/docs/publish-whatfix-content) so that the latest behavior reflects for your end users.
