Skip to content

Commit a20d77f

Browse files
committed
feat: add comprehensive meta tags and fix Google Analytics implementation
1 parent 3a728c8 commit a20d77f

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

src/components/google-analytics.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
"use client";
22

33
import Script from "next/script";
4+
import { usePathname, useSearchParams } from 'next/navigation';
45
import { useEffect } from "react";
56

7+
const GA_MEASUREMENT_ID = "G-ZZBSKJSFZ8";
8+
69
const GoogleAnalytics = () => {
10+
const pathname = usePathname();
11+
const searchParams = useSearchParams();
12+
713
useEffect(() => {
8-
if (typeof window !== "undefined") {
9-
window.dataLayer = window.dataLayer || [];
10-
const gtag = (...args: any[]) => {
11-
window.dataLayer.push(args);
12-
};
13-
gtag("js", new Date());
14-
gtag("config", "G-ZZBSKJSFZ8");
14+
if (typeof window !== "undefined" && window.gtag) {
15+
window.gtag('config', GA_MEASUREMENT_ID, {
16+
page_path: pathname + (searchParams?.toString() ? `?${searchParams.toString()}` : ''),
17+
send_page_view: true
18+
});
1519
}
16-
}, []);
20+
}, [pathname, searchParams]);
1721

1822
return (
19-
<Script
20-
async
21-
src="https://www.googletagmanager.com/gtag/js?id=G-ZZBSKJSFZ8"
22-
/>
23+
<>
24+
<Script
25+
strategy="afterInteractive"
26+
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
27+
/>
28+
<Script
29+
id="google-analytics"
30+
strategy="afterInteractive"
31+
>
32+
{`
33+
window.dataLayer = window.dataLayer || [];
34+
function gtag(){dataLayer.push(arguments);}
35+
gtag('js', new Date());
36+
gtag('config', '${GA_MEASUREMENT_ID}', {
37+
page_path: window.location.pathname + window.location.search,
38+
send_page_view: true
39+
});
40+
`}
41+
</Script>
42+
</>
2343
);
2444
};
2545

theme.config.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,27 @@ const config: DocsThemeConfig = {
1414
head: (
1515
<>
1616
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
17-
<meta property="og:title" content="Bruno Docs" />
18-
<meta property="og:description" content="The open-source API Client" />
17+
<meta name="description" content="Bruno is a fast and git-friendly open source API client, helping developers test and manage APIs efficiently." />
18+
<meta name="keywords" content="API client, API testing, Postman alternative, REST client, GraphQL client, SOAP client, API development, git-friendly API client" />
19+
<meta name="robots" content="index, follow" />
20+
21+
{/* Open Graph */}
22+
<meta property="og:title" content="Bruno - The Open Source API Client" />
23+
<meta property="og:description" content="Fast and git-friendly open source API client for testing and managing APIs" />
24+
<meta property="og:type" content="website" />
25+
<meta property="og:url" content="https://docs.usebruno.com" />
26+
<meta property="og:image" content="https://docs.usebruno.com/bruno.png" />
27+
<meta property="og:site_name" content="Bruno Docs" />
28+
29+
{/* Twitter Card */}
30+
<meta name="twitter:card" content="summary_large_image" />
31+
<meta name="twitter:title" content="Bruno - The Open Source API Client" />
32+
<meta name="twitter:description" content="Fast and git-friendly open source API client for testing and managing APIs" />
33+
<meta name="twitter:image" content="https://docs.usebruno.com/bruno.png" />
34+
1935
<link href="/bruno.png" rel="icon" type="image/png" sizes="32x32" />
2036
<link href="/bruno.png" rel="apple-touch-icon" type="image/png" sizes="32x32" />
37+
<link rel="canonical" href="https://docs.usebruno.com" />
2138
</>
2239
),
2340
navbar: {

0 commit comments

Comments
 (0)