Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional tracking pixel #126

Merged
merged 2 commits into from
May 3, 2024
Merged

Conversation

eric-schneider
Copy link
Contributor

@eric-schneider eric-schneider commented May 2, 2024

JIRA: DOC-4013
Resolves: #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
Copy link
Contributor

mlr commented May 2, 2024

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

@mlr
Copy link
Contributor

mlr commented May 2, 2024

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

@eric-schneider eric-schneider changed the title DOC-4013: Add conditional tracking pixel Add conditional tracking pixel May 2, 2024
src/partials/body.hbs Outdated Show resolved Hide resolved
Copy link
Collaborator

@colegoldsmith colegoldsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the discussion I would suggest moving to body-end-scripts but it's not a huge deal. Looks good otherwise!

@colegoldsmith
Copy link
Collaborator

@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
Copy link
Contributor

mlr commented May 2, 2024

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

@mlr
Copy link
Contributor

mlr commented May 2, 2024

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

@eric-schneider eric-schneider merged commit 7516b54 into main May 3, 2024
2 checks passed
@eric-schneider eric-schneider deleted the DOC-4013-tracking-pixel branch May 3, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants