mirror of
https://github.com/google/nomulus.git
synced 2025-05-09 08:18:21 +02:00
To support the open source community, which may want to use different analytics services, we implement a soy template for analytics services that: 1) Does not require users to implement Google Analytics 2) Allows users to add their own analytics code to `Analytics.soy` 3) Gives users the flexibility to pass as much or as little static configuration to their custom analytics code as needed. 4) Ensures that users can merge upstream Nomulus code in the future without having to delete their custom analytics implementations 5) Does not allow code to be injected from configuration, which Soy as a framework actively discourages. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=248340081
34 lines
1.2 KiB
Text
34 lines
1.2 KiB
Text
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
{namespace registry.soy.analytics}
|
|
|
|
/**
|
|
* The JS template required to install Google Analytics for the registrar console.
|
|
*/
|
|
{template .googleAnalytics}
|
|
{@param analyticsConfig: [googleAnalyticsId: string|null]}
|
|
{let $id: $analyticsConfig.googleAnalyticsId /}
|
|
|
|
{if $id}
|
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id={$id}"></script>
|
|
<script>
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){lb}dataLayer.push(arguments);{rb}
|
|
gtag('js', new Date());
|
|
gtag('config', {$id});
|
|
</script>
|
|
{/if}
|
|
{/template}
|
|
|