Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ module.exports = {
},
}),
},
// Meta Pixel Code
{
tagName: "script",
attributes: {},
innerHTML: `!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '2006330080011702');
Comment thread
dhananjay6561 marked this conversation as resolved.
fbq('track', 'PageView');`,
},
{
tagName: "noscript",
attributes: {},
innerHTML: `<img height="1" width="1" style="display:none" alt="" src="https://www.facebook.com/tr?id=2006330080011702&ev=PageView&noscript=1" />`,
},
// End Meta Pixel Code
],
title: "Keploy Documentation",
titleDelimiter: "🐰",
Expand Down Expand Up @@ -549,6 +570,7 @@ module.exports = {
],
],

clientModules: [require.resolve("./src/metaPixelRouteTracker.js")],
scripts: [
{
src: "/docs/scripts/feedback.js",
Expand Down
11 changes: 11 additions & 0 deletions src/metaPixelRouteTracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Re-fire Meta Pixel PageView on client-side route changes.
// The base snippet in docusaurus.config.js (headTags) only fires PageView on
// the initial load; Docusaurus is an SPA, so in-app navigation must be tracked
// explicitly here.
export function onRouteDidUpdate({location, previousLocation}) {
if (previousLocation && location.pathname !== previousLocation.pathname) {
if (typeof window.fbq === "function") {
window.fbq("track", "PageView");
}
}
}
Loading