Skip to content

WIP: enable Adobe analytics #838

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

Merged
merged 18 commits into from
Jun 11, 2025
Merged
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
56 changes: 56 additions & 0 deletions source/_static/analytics-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* The name of the analytics event property in the data-* attributes.
*/
const datasetEventProperty = "analyticsEvent";

/**
* List of properties set in the data-* attributes of the element
* that will be passed into the eventInfo object.
*/
const datasetEntries = [
["analyticsAction", "action"],
["analyticsDetail", "detail"],
["analyticsLabel", "label"],
["analyticsLocation", "location"],
];

const datasetProperties = new Map(datasetEntries);
Object.freeze(datasetProperties);

function handleAnalyticsEvent({ event, eventInfo }) {
window.adobeDataLayer = window.adobeDataLayer || [];
window.adobeDataLayer.push({
event,
eventInfo,
});
}

document.addEventListener("click", function (event) {
const { target } = event;

let element = target;
// eslint-disable-next-line security/detect-object-injection
if (element.dataset[datasetEventProperty]) {
element = target;
} else {
element = target.closest("[data-analytics-event]");
}

if (element) {
const { dataset } = element;

const eventInfo = {};
for (const [property, analyticsValue] of datasetProperties) {
if (Object.hasOwn(dataset, property)) {
// eslint-disable-next-line security/detect-object-injection
eventInfo[analyticsValue] = dataset[property];
}
}

handleAnalyticsEvent({
// eslint-disable-next-line security/detect-object-injection
event: dataset[datasetEventProperty],
eventInfo,
});
}
});
27 changes: 26 additions & 1 deletion source/_static/theme_overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,29 @@ body {
min-height:100%;
background:#edf0f2
}
.wy-text-left {

.is-flex {
display: flex !important;
}

.is-flex-direction-row {
flex-direction: row !important;
}

.has-gap-4 {
gap: 1rem !important;
}

.is-link {
color: #2980b9 !important;
text-decoration: inherit;
background-color: transparent !important;
border: none !important;
padding: 0;
margin: 0;
}

.is-link:hover {
color: #3091d1 !important;
outline: 0;
}
79 changes: 79 additions & 0 deletions source/_templates/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{%- if meta is defined and meta is not none %}
{%- set check_meta = True %}
{%- else %}
{%- set check_meta = False %}
{%- endif %}

{%- if check_meta and 'github_url' in meta %}
{%- set display_github = True %}
{%- endif %}

{%- if check_meta and 'bitbucket_url' in meta %}
{%- set display_bitbucket = True %}
{%- endif %}

{%- if check_meta and 'gitlab_url' in meta %}
{%- set display_gitlab = True %}
{%- endif %}

{%- set display_vcs_links = display_vcs_links if display_vcs_links is defined else True %}

{#- Translators: This is an ARIA section label for page links, including previous/next page link and links to GitHub/GitLab/etc. -#}
<div role="navigation" aria-label="{{ _('Page navigation') }}">
<ul class="wy-breadcrumbs">
{%- block breadcrumbs %}
<li>
<a href="{{ pathto(master_doc) }}" class="icon icon-home" aria-label="Home" data-analytics-event="megamenu" data-analytics-action="click" data-analytics-label="megamenu" data-analytics-detail="home" data-analytics-location="{{ pathto(master_doc) }}"></a>
</li>
{%- for doc in parents %}
<li class="breadcrumb-item"><a href="{{ doc.link|e }}" data-analytics-event="breadcrumb" data-analytics-action="click" data-analytics-label="{{ doc.title }}" data-analytics-detail="{{ doc.title }}" data-analytics-location="{{ doc.link|e }}">{{ doc.title }}</a></li>
{%- endfor %}
<li class="breadcrumb-item active">{{ title }}</li>
{%- endblock %}
{%- block breadcrumbs_aside %}
<li class="wy-breadcrumbs-aside">
{%- if hasdoc(pagename) and display_vcs_links %}
{%- if display_github %}
{%- if check_meta and 'github_url' in meta %}
<!-- User defined GitHub URL -->
<a href="{{ meta['github_url'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
{%- else %}
<a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode or "blob" }}/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ page_source_suffix }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
{%- endif %}
{%- elif display_bitbucket %}
{%- if check_meta and 'bitbucket_url' in meta %}
<!-- User defined Bitbucket URL -->
<a href="{{ meta['bitbucket_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a>
{%- else %}
<a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}/src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}{{ page_source_suffix }}?mode={{ theme_vcs_pageview_mode or "view" }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a>
{%- endif %}
{%- elif display_gitlab %}
{%- if check_meta and 'gitlab_url' in meta %}
<!-- User defined GitLab URL -->
<a href="{{ meta['gitlab_url'] }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a>
{%- else %}
<a href="https://{{ gitlab_host|default("gitlab.com") }}/{{ gitlab_user }}/{{ gitlab_repo }}/{{ theme_vcs_pageview_mode or "blob" }}/{{ gitlab_version }}{{ conf_py_path }}{{ pagename }}{{ page_source_suffix }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a>
{%- endif %}
{%- elif show_source and source_url_prefix %}
<a href="{{ source_url_prefix }}{{ pagename }}{{ page_source_suffix }}">{{ _('View page source') }}</a>
{%- elif show_source and has_source and sourcename %}
<a href="{{ pathto('_sources/' + sourcename, true)|e }}" rel="nofollow"> {{ _('View page source') }}</a>
{%- endif %}
{%- endif %}
</li>
{%- endblock %}
</ul>

{%- if (theme_prev_next_buttons_location == 'top' or theme_prev_next_buttons_location == 'both') and (next or prev) %}
{#- Translators: This is an ARIA section label for sequential page links, such as previous and next page links. -#}
<div class="rst-breadcrumbs-buttons" role="navigation" aria-label="{{ _('Sequential page navigation') }}">
{%- if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral float-left" title="{{ prev.title|striptags|e }}" accesskey="p" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="{{ prev.title|striptags|e }}" data-analytics-location="{{ prev.link|e }}"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> {{ _('Previous') }}</a>
{%- endif %}
{%- if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="{{ next.title|striptags|e }}" data-analytics-location="{{ next.link|e }}">{{ _('Next') }} <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
{%- endif %}
</div>
{%- endif %}
<hr/>
</div>
94 changes: 82 additions & 12 deletions source/_templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,85 @@
{% extends "!footer.html" %}
{%-block contentinfo %}
<footer>
{%- if (theme_prev_next_buttons_location == 'bottom' or theme_prev_next_buttons_location == 'both') and (next or prev) %}
{#- Translators: This is an ARIA section label for the footer section of the page. -#}
<div class="rst-footer-buttons" role="navigation" aria-label="{{ _('Footer') }}">
{%- if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral float-left" title="{{ prev.title|striptags|e }}" accesskey="p" rel="prev" data-analytics-event="cta" data-analytics-action="click" data-analytics-label="previous" data-analytics-detail="{{ prev.title|striptags|e }}" data-analytics-location="{{ prev.link|e }}"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> {{ _('Previous') }}</a>
{%- endif %}
{%- if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n" rel="next" data-analytics-event="cta" data-analytics-action="click" data-analytics-label="next" data-analytics-detail="{{ next.title|striptags|e }}" data-analytics-location="{{ next.link|e }}">{{ _('Next') }} <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
{%- endif %}
</div>
{%- endif %}

<div class="download" data-toggle="link" role="note" aria-label="Link">
<a href="https://github.com/foundriesio/docs/{{ gh_release }}/" target="_blank" rel="noreferrer noopener" Link>
<button type="button" button style="margin:10px;"> Offline Version </button>
</a>
</div>
<hr/>

<div class="has-text-centered is-size-7 mb-2 px-6 mx-6">
<p>Linux<sup>&reg;</sup> is the registered trademark of Linus Torvalds in the U.S. and other countries.</p>
</div>
{{ super() }}
<div role="contentinfo">
{%- block contentinfo %}
<p class="is-flex is-flex-direction-row has-gap-4">
<a href="https://github.com/foundriesio/docs/{{ gh_release }}/" target="_blank" rel="noreferrer noopener" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="offline version" data-analytics-location="https://github.com/foundriesio/docs/{{ gh_release }}/">
Offline Version
</a>

{% endblock %}
<a href="https://foundries.io/company/privacy/" target="_blank" rel="noreferrer noopener" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="privacy policy" data-analytics-location="https://foundries.io/company/privacy/">
Privacy Policy
</a>

<a href="https://foundries.io/company/cookie-policy/" target="_blank" rel="noreferrer noopener" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="cookie policy" data-analytics-location="https://foundries.io/company/cookie-policy/">
Cookie Policy
</a>

{%- if adobe_analytics_url %}
{# Needed for Adobe analytics and OneTrust cookie choice to work, need to be kept as is with its ID and ot-sdk-* class. #}
<a class="ot-sdk-show-settings is-link" id="ot-sdk-btn">Cookie Settings</a>
{%- endif %}
</p>

<p>
Linux<sup>&reg;</sup> is the registered trademark of Linus Torvalds in the U.S. and other countries.
</p>

<p>
{%- if show_copyright %}
{%- if hasdoc('copyright') %}
{%- trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{%- else %}
{%- trans copyright=copyright|e %}&#169; Copyright {{ copyright }}.{% endtrans %}
{%- endif %}
{%- endif %}

{%- if build_id and build_url %}
<span class="build">
{#- Translators: Build is a noun, not a verb -#}
{%- trans %}Build{% endtrans -%}
<a href="{{ build_url }}">{{ build_id }}</a>.
</span>
{%- elif commit %}
<span class="commit">
{#- Translators: the phrase "revision" comes from Git, referring to a commit #}
{%- trans %}Revision{% endtrans %} <code>{{ commit }}</code>.
</span>
{%- endif %}
{%- if last_updated %}
<span class="lastupdated">
{%- trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
</span>
{%- endif -%}

</p>
{%- endblock %}
</div>

{% if show_sphinx %}
{%- set sphinx_web = '<a href="https://www.sphinx-doc.org/" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="Sphinx" data-analytics-location="https://www.sphinx-doc.org">Sphinx</a>' %}
{%- set readthedocs_web = '<a href="https://readthedocs.org" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="Read the Docs" data-analytics-location="https://readthedocs.org">Read the Docs</a>' %}
{#- Translators: the variable "sphinx_web" is a link to the Sphinx project documentation with the text "Sphinx" #}
{%- trans sphinx_web=sphinx_web, readthedocs_web=readthedocs_web %}Built with {{ sphinx_web }} using a{% endtrans %}
{#- Translators: "theme" refers to a theme for Sphinx, which alters the appearance of the generated documentation #}
<a href="https://github.com/readthedocs/sphinx_rtd_theme" data-analytics-event="footer" data-analytics-action="click" data-analytics-label="footer" data-analytics-detail="theme" data-analytics-location="https://github.com/readthedocs/sphinx_rtd_theme">{% trans %}theme{% endtrans %}</a>
{#- Translators: this is always used as "provided by Read the Docs", and should not imply Read the Docs is an author of the generated documentation. #}
{% trans %}provided by {{ readthedocs_web }}{% endtrans %}.
{% endif %}

{%- block extrafooter %} {% endblock %}

</footer>
Loading