# Tracking Button Clicks

## Overview

Track when the user clicks a button, and use that to show/hide elements on other pages throughout your site.

## Implementing

Place this code inside the BODY custom code area of your page or site.

If the button is only on one page, it's best to put it on that page only, to prevent ID conflicts with elements on other pages.

If the button is on all pages, such as a nav or footer button, it's best to place it in the site-wide BODY custom code, under site settings.&#x20;

{% code overflow="wrap" %}

```html

<script>
// Handle button tracking 
$("#button").click(function() {
  window.tracker.track("button-clicked");
  updateTracked();
}); 
</script>
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://attr.sygnal.com/sa5-track/webflow-cookies-and-storage-tracking/tracking-button-clicks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
