Third-Party Analytics| Hitchhikers Platform

Adding third-party analytics e.g. Google Analytics, requires adding a script tag to the head of your HTML documents. This is easily accomplished in Pages using the getHeadConfig export.

Process

To add an arbitrary script tag to your templates, use the other property on the HeadConfig object.

The other property is used for any content that can’t be fully encapsulated by the Tag interface. An arbitrary, user-defined string can be provided. Here is an example:

export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({ document }): HeadConfig => {
  return {
    title: document.name,
    charset: "UTF-8",
    viewport: "width=device-width, initial-scale=1",
    tags: [
      {
        type: "meta",
        attributes: {
          description: "This site was generated by the Yext SSG",
        },
      },
    ],
    other: `INSERT YOUR THIRD-PARTY SCRIPT TAG HERE` // Replace this string
  };
};
light bulb
Tip
Make sure to include your tag on every Page where you want tracking.
Feedback