mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-01 09:04:03 +00:00
docs[patch]: Update how GA4 is collected (#18821)
There's some issue/setting with the current python GA4 app. I created a new one just for feedback.
This commit is contained in:
parent
a8de6d1533
commit
9c218d0154
@ -335,6 +335,10 @@ const config = {
|
|||||||
src: "https://www.googletagmanager.com/gtag/js?id=G-9B66JQQH2F",
|
src: "https://www.googletagmanager.com/gtag/js?id=G-9B66JQQH2F",
|
||||||
async: true,
|
async: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
src: "https://www.googletagmanager.com/gtag/js?id=G-WFT0J048RF",
|
||||||
|
async: true,
|
||||||
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export default function gtag(...args) {
|
export default function gtag(...args) {
|
||||||
if (window.gtag) {
|
if (window.gtagFeedback) {
|
||||||
window.gtag(...args);
|
window.gtagFeedback(...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ export default function Feedback() {
|
|||||||
const [feedbackSent, setFeedbackSent] = useState(false);
|
const [feedbackSent, setFeedbackSent] = useState(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {"yes" | "no"} feedback
|
* @param {"good" | "bad"} feedback
|
||||||
*/
|
*/
|
||||||
const handleFeedback = (feedback) => {
|
const handleFeedback = (feedback) => {
|
||||||
const cookieName = `${FEEDBACK_COOKIE_PREFIX}_${window.location.pathname}`;
|
const cookieName = `${FEEDBACK_COOKIE_PREFIX}_${window.location.pathname}`;
|
||||||
@ -105,15 +105,12 @@ export default function Feedback() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const feedbackType =
|
const feedbackEnv =
|
||||||
process.env.NODE_ENV === "production"
|
process.env.NODE_ENV === "production"
|
||||||
? "page_feedback"
|
? "page_feedback"
|
||||||
: "page_feedback_dev";
|
: "page_feedback_dev";
|
||||||
|
|
||||||
gtag("event", feedbackType, {
|
gtag("event", `${feedbackEnv}_${feedback}`, {});
|
||||||
url: window.location.pathname,
|
|
||||||
feedback,
|
|
||||||
});
|
|
||||||
// Set a cookie to prevent feedback from being sent multiple times
|
// Set a cookie to prevent feedback from being sent multiple times
|
||||||
setCookie(cookieName, window.location.pathname, 1);
|
setCookie(cookieName, window.location.pathname, 1);
|
||||||
setFeedbackSent(true);
|
setFeedbackSent(true);
|
||||||
@ -168,12 +165,12 @@ export default function Feedback() {
|
|||||||
// Handle keyboard interaction
|
// Handle keyboard interaction
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleFeedback("yes");
|
handleFeedback("good");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleFeedback("yes");
|
handleFeedback("good");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SvgThumbsUp />
|
<SvgThumbsUp />
|
||||||
@ -186,12 +183,12 @@ export default function Feedback() {
|
|||||||
// Handle keyboard interaction
|
// Handle keyboard interaction
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleFeedback("no");
|
handleFeedback("bad");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleFeedback("no");
|
handleFeedback("bad");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SvgThumbsDown />
|
<SvgThumbsDown />
|
||||||
|
14
docs/static/js/google_analytics.js
vendored
14
docs/static/js/google_analytics.js
vendored
@ -1,7 +1,11 @@
|
|||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag() {
|
function gtag(){dataLayer.push(arguments);}
|
||||||
dataLayer.push(arguments);
|
gtag('js', new Date());
|
||||||
}
|
|
||||||
gtag("js", new Date());
|
|
||||||
|
|
||||||
gtag("config", "G-9B66JQQH2F");
|
gtag('config', 'G-9B66JQQH2F');
|
||||||
|
|
||||||
|
// Only for feedback
|
||||||
|
function gtagFeedback(){dataLayer.push(arguments);}
|
||||||
|
gtagFeedback('js', new Date());
|
||||||
|
|
||||||
|
gtagFeedback('config', 'G-WFT0J048RF');
|
Loading…
Reference in New Issue
Block a user