1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-25 15:38:01 +02:00

Move GA code directly into main page (#289)

This replaces a bit of code with the equivalent HTML code.

We also load the script async, which means that the browser won’t
block rendering while waiting for the scripts.
This commit is contained in:
Martin Geisler 2023-01-27 14:37:17 +01:00 committed by GitHub
parent 1453e1d5bb
commit 4409f330c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 16 deletions

16
ga4.js
View File

@ -12,22 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Setup cookie consent banner.
var consent = document.createElement('script');
consent.setAttribute('data-autoload-cookie-consent-bar', 'true');
consent.setAttribute('src', 'https://www.gstatic.com/brandstudio/kato/cookie_choice_component/cookie_consent_bar.v3.js');
document.head.appendChild(consent);
// Load and configure Google Analytics.
var ga4 = document.createElement('script');
ga4.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=G-ZN78TEJMRW');
document.head.appendChild(ga4);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZN78TEJMRW');
// Look through all Playgrounds on the page to determine if the code snippet
// matches one of the. If the code is different from all Playgrounds, we
// conclude that the user modified the Playground before submitting it.

View File

@ -11,6 +11,16 @@
<base href="{{ base_url }}">
{{/if}}
<script async src="https://www.gstatic.com/brandstudio/kato/cookie_choice_component/cookie_consent_bar.v3.js"
data-autoload-cookie-consent-bar="true"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZN78TEJMRW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZN78TEJMRW');
</script>
<!-- Custom HTML head -->
{{> head}}