Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Enhance filter functionality in BaseStandardSection component and update Google Tag Manager documentation formatting

Bill Yang473eac01a5bb
diff --git a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
index 4be93b192..a5d1b1506 100644
--- a/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
+++ b/client/src/app/[site]/components/shared/StandardSection/BaseStandardSection.tsx
@@ -3,14 +3,18 @@ import NumberFlow from "@number-flow/react";
import { round } from "lodash";
import {
AlertCircle,
- Expand,
Info,
RefreshCcw,
SquareArrowOutUpRight,
} from "lucide-react";
import { ReactNode } from "react";
import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";
-import { addFilter, FilterParameter } from "../../../../../lib/store";
+import {
+ addFilter,
+ FilterParameter,
+ removeFilter,
+ useStore,
+} from "../../../../../lib/store";
import { BaseStandardSectionDialog } from "./BaseStandardSectionDialog";
import { Skeleton } from "./Skeleton";
@@ -31,17 +35,28 @@ export const Row = ({
getLink?: (item: SingleColResponse) => string;
filterParameter: FilterParameter;
}) => {
+ const filters = useStore((state) => state.filters);
+
return (
<div
key={getKey(e)}
className="relative h-6 flex items-center cursor-pointer hover:bg-neutral-850 group"
- onClick={() =>
- addFilter({
- parameter: filterParameter,
- value: [getValue(e)],
- type: "equals",
- })
- }
+ onClick={() => {
+ const foundFilter = filters.find(
+ (f) =>
+ f.parameter === filterParameter &&
+ f.value.some((v) => v === getValue(e))
+ );
+ if (foundFilter) {
+ removeFilter(foundFilter);
+ } else {
+ addFilter({
+ parameter: filterParameter,
+ value: [getValue(e)],
+ type: "equals",
+ });
+ }
+ }}
>
<div
className="absolute inset-0 bg-dataviz py-2 opacity-25 rounded-md"
diff --git a/docs/src/content/google-tag-manager.mdx b/docs/src/content/google-tag-manager.mdx
index 2850d0e03..8c3080a2c 100644
--- a/docs/src/content/google-tag-manager.mdx
+++ b/docs/src/content/google-tag-manager.mdx
@@ -7,7 +7,7 @@ Google Tag Manager (GTM) allows you to add code snippets or tracking pixels to y
## How to Add Rybbit to Google Tag Manager
<Steps>
-### 1. **Retrieve Your Tracking Script**
+### 1. Retrieve Your Tracking Script
Navigate to your Rybbit instance to obtain your JavaScript snippet.
@@ -35,23 +35,23 @@ However, GTM sanitizes script tags by removing non-standard HTML attributes like
</script>
```
-### 2. **Access Your GTM Dashboard**
+### 2. Access Your GTM Dashboard
Assuming GTM is already set up, go to your GTM dashboard and select the appropriate account and container linked to your website.
-### 3. **Create a New Tag**
+### 3. Create a New Tag
Click on "Add a new tag" to initiate the creation process.
-### 4. **Configure the Tag**
+### 4. Configure the Tag
Under "Tag Configuration," choose "Custom HTML" and paste your Rybbit snippet into the provided field.
-### 5. **Set Up Triggers**
+### 5. Set Up Triggers
Assign a trigger to determine when the tag should fire. For instance, to load Rybbit on all pages, select the "All Pages" trigger.
-### 6. **Save and Publish**
+### 6. Save and Publish
Save your changes and publish the container to make the tag active on your website.
</Steps>