# Click Activity and Field Edit Tracking for Web Applications

This rule tracks user interactions in web-based enterprise applications, capturing click events and field edits while filtering unnecessary interactions. Tab switches within the same application are also recorded unless explicitly excluded.

### Key Capabilities

* Tracks all click interactions by default.
* Customizable filtering for relevant UI elements.
* Separate logging for field edits.

### Configuration & Customization

1. **Tracking All Clicks (Default)**
   * Logs every UI element clicked under Activity Analysis.
2. **Filtering Click Interactions (Customizable)**
   * Users can specify which UI elements to track.
   * Only clicks on listed elements (`collect_only` context) are extracted.
3. **Field Edits Extraction**
   * Tracks interactions with fields (e.g., form inputs, selection lists) under Field Edits.

### JSON Code

<details>

<summary>Expand to see an example</summary>

{% code title="salesforce\_case\_advanced\_click\_and\_field\_edit\_elements\_json" lineNumbers="true" %}

```json
{
  "id": "dab52ad4-3193-43f1-a3d4-5403c33fffb9",
  "tags": [],
  "allow_tracking": true,
  "extract_identifiers": [],
  "salvage_fields": ["reaction_execution_logs"],
  "reactions": [
    {
      "on": ["LeftClick"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "click_action",
            "If": {
              "Condition": "Name in Context.collect_only",
              "Context": {
                "collect_only": [
                  "Feed",
                  "Details",
                  "Related",
                  "Tracking, Closing & NPS",
                  "NPS",
                  "Order And Site Information",
                  "Post",
                  "Email",
                  "Log a Call",
                  "New Task",
                  "Sub Case: Copy Parent Details",
                  "Close SPAM Case",
                  "Generate Doc",
                  "Request Update from Service",
                  "Request Site/Installation creation",
                  "Complaint Sub-Case",
                  "Sub Case: Modify Parent Details",
                  "Send to SAP",
                  "Update Case",
                  "Activity",
                  "Knowledge",
                  "Mark Status as Complete",
                  "Share",
                  "Cancel",
                  "Save",
                  "Send",
                  "Run Macro",
                  "Edit",
                  "Add",
                  "Follow",
                  "Clone",
                  "Close Case"
                ]
              }
            }
          }
        }
      ]
    },
    {
      "on": ["Paste"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "paste_field_name"
          }
        }
      ]
    },
    {
      "on": ["Copy"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "copy_field_name"
          }
        }
      ]
    },
    {
      "on": ["LeftClick"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "field_edit",
            "If": {
              "Condition": "Name in Context.collect_only",
              "Context": {
                "collect_only": [
                  "Change Owner",
                  "Description",
                  "Technical Details",
                  "Serial Number",
                  "Sales Order Number",
                  "ABC Order Number",
                  "Purchase Order Number",
                  "Estimated Value",
                  "Invoice Number",
                  "Internal Reference",
                  "Product Search Criteria",
                  "Error Code",
                  "Error Description",
                  "Contact Name",
                  "Contact Email",
                  "Contact Mobile",
                  "Contact Phone",
                  "Subject",
                  "Internal Comments"
                ]
              }
            }
          }
        }
      ]
    },
    {
      "on": ["LeftClick"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": {
            "Child": 0
          }
        },
        {
          "Go": {
            "Child": 0
          }
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "field_edit",
            "If": {
              "Condition": "Name in Context.collect_only",
              "Context": {
                "collect_only": [
                  "Product Group",
                  "Case Sub Type",
                  "Case Resolution",
                  "Type",
                  "Case Reason",
                  "Product",
                  "Potential Liability",
                  "Status",
                  "Priority",
                  "Severity",
                  "Product Group",
                  "Case Sub Type"
                ]
              }
            }
          }
        }
      ]
    },
    {
      "on": ["LeftClick"],
      "react": [
        {
          "Go": "Focus"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": "Parent"
        },
        {
          "Go": {
            "Child": 0
          }
        },
        {
          "Go": {
            "Child": 1
          }
        },
        {
          "Extract": {
            "Property": "Name",
            "As": "field_edit",
            "If": {
              "Condition": "Name in Context.collect_only",
              "Context": {
                "collect_only": [
                  "Business Area",
                  "Division",
                  "Case Origin",
                  "Support Type",
                  "Case Type",
                  "Status",
                  "Originating Country"
                ]
              }
            }
          }
        }
      ]
    }
  ],
  "matching_criteria": {
    "rule_engine_rule": "active_process_name_lower in context.process_name and url_parsed&['netloc'] == context['netloc'] and url_parsed&.path and context['path'] in url_parsed&.path and not context['no_path'] in url_parsed&.path and not context.no_query in url_parsed&.query.params",
    "context": {
      "netloc": "lightning.force.com",
      "path": "/Case",
      "no_path": "/Case/list",
      "no_query": "uid"
    }
  }
}
```

{% endcode %}

</details>

{% file src="<https://2793813092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8GkXjeUIZVdsIJygBmnf%2Fuploads%2FOWkNa7j8BIZBGjcYc5gk%2Fsalesforce_case_advanced_click_and_field_edit_elements_json.json?alt=media&token=a13c953f-4591-4e31-83b8-43af9f85580a>" %}

### Explanation

1. **Click Tracking & Activity Analysis**
   * UI element clicks are extracted under `click_action`.
   * Users can filter which elements to include using `collect_only`.
   * Logged interactions appear in Activity Analysis.
2. **Field Edits & Process Analysis**
   * Clicking an editable field triggers a separate `field_edit` extraction.
   * These interactions are categorized under Field Edits.
3. **URL-Based Matching**
   * Ensures tracking applies only when the active page matches specified URLs.

### User Benefits

* **Improved Interaction Analysis**: Logs all interactions for process efficiency insights.
* **Customization for Precision**: Allows refining tracking to focus on meaningful interactions.
* **Field Edit Visibility**: Categorizes user edits separately for tracking.

### Expected Outcome

* **Activity Analysis View**: Displays all tracked interactions.
* **Field Edits View**: Captures user-modified fields separately.
* **Process Optimization**: Helps teams refine workflows based on real user interactions.
