Dev Portal is highly extensible. You can create custom plugins to add new functionality to your documentation site. This guide will show you how to create and use plugins in your Dev Portal configuration.
Plugin Types
All plugins in Dev Portal must implement the ZudokuPlugin type, which is a union of these plugin interfaces:
CommonPlugin: Basic plugin with initialization, head elements, and MDX component customization
ProfileMenuPlugin: Add custom items to the profile menu
NavigationPlugin: Define custom routes and sidebar items
ApiIdentityPlugin: Provide API identities for testing
Below is a sample of adding the necessary scripts for GTM, but this could apply to any tag manager or tracking script.
Code
import { ZudokuPlugin } from "zudoku";const commonPlugin: ZudokuPlugin = { getHead: () => { return ( <script> {` (function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", "GTM-<YOUR GTM ID HERE>");`} </script> ); },};
Tracking page_view Events
Dev Portal is a single page application so typical page_view events are not captured by most analytics scripts or tag managers. Instead, you must listen to the locationevent with a plugin and log navigation changes in code.