riptano / docs-ui

The UI and theme for DataStax Docs.
https://riptano.github.io/docs-ui/
Mozilla Public License 2.0
2 stars 0 forks source link

Add conditional tracking pixel #126

Closed eric-schneider closed 2 months ago

eric-schneider commented 2 months ago

JIRA: DOC-4013 Resolves: https://github.com/riptano/docs-ui/issues/117

This PR adds a new partial, tracking-pixel.hbs, that implements a conditional tracking pixel with a variable ID. The tracking pixel code will only get built into pages when the site.keys.scarf_tracking_pixel key is defined in the playbook and assigned a value:

site:
  keys:
    scarf_tracking_pixel: 'PIXEL_ID'

See related playbook change.

From what I understand, tracking pixels are usually placed right before the closing </body> tag so that they don’t delay the loading of any visible content. For this reason, I've inserted the tracking-pixel partial at the bottom of body.hbs.

@colegoldsmith, this ensures that the pixel will get included on every page, correct?

I've also seen it suggested that it's a good idea to hide the pixel with a CSS style so that the pixel doesn’t interact with other CSS on the page. For this reason, I've added style="display:none to the pixel.

mlr commented 2 months ago

UI bundle preview build successful! :white_check_mark: Deploying preview to GitHub Pages. Deployment successful! View preview

mlr commented 2 months ago

Antora site build successful! :white_check_mark: Deploying draft to GitHub Pages. Deployment successful! View draft

colegoldsmith commented 2 months ago

@eric-schneider To answer your question, yep adding this to the partials will include it on every page as long as the site.keys.scarf_tracking_pixel exists

mlr commented 2 months ago

UI bundle preview build successful! :white_check_mark: Deploying preview to GitHub Pages. Deployment successful! View preview

mlr commented 2 months ago

Antora site build successful! :white_check_mark: Deploying draft to GitHub Pages. Deployment successful! View draft