Skip to content

Commit 76d6671

Browse files
committed
Restore the gtag JavaScript function to re-enable metrics
The associated issue is in the pytorch/tutorials repository: Issue #2696 · [BUG] No longer collecting star-rating data...since transition to GA4 pytorch/tutorials#2696 The gtag function is used by metrics such as star-rating in the tutorials repository (which leverages pytorch_sphinx_theme). The definition for the gtag function was deleted in the transition to Google Analytics 4 (GA4) in PR#182, which in-turn broke our metrics. This commit restores the definition of the function to re-enable these metrics.
1 parent cf6f6cd commit 76d6671

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pytorch_sphinx_theme/layout.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
8282
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
8383
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
84-
})(window,document,'script','dataLayer','{{ theme_analytics_id }}');</script>
84+
})(window,document,'script','dataLayer','{{ theme_analytics_id }}');
85+
function gtag(){dataLayer.push(arguments);}
86+
</script>
8587
<!-- End Google Tag Manager -->
8688
{% endblock %}
8789

0 commit comments

Comments
 (0)