Merge pull request #1311 from cisagov/nmb/513-google-analytics

#513: Add google analytics code in production
This commit is contained in:
Neil MartinsenBurrell 2023-11-13 09:05:30 -06:00 committed by GitHub
commit 88ab9a4f08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 3 deletions

View file

@ -29,6 +29,8 @@ services:
- IS_PRODUCTION=False
# Tell Django where it is being hosted
- DJANGO_BASE_URL=http://localhost:8080
# Is this a production environment
- IS_PRODUCTION
# Public site URL link
- GETGOV_PUBLIC_SITE_URL=https://beta.get.gov
# Set a username for accessing the registry

View file

@ -210,6 +210,7 @@ TEMPLATES = [
"registrar.context_processors.language_code",
"registrar.context_processors.canonical_path",
"registrar.context_processors.is_demo_site",
"registrar.context_processors.is_production",
],
},
},

View file

@ -31,3 +31,8 @@ def is_demo_site(request):
should not appear.
"""
return {"IS_DEMO_SITE": settings.IS_DEMO_SITE}
def is_production(request):
"""Add a boolean if this is our production site."""
return {"IS_PRODUCTION": settings.IS_PRODUCTION}

View file

@ -3,6 +3,14 @@
<html class="no-js" lang="{{ LANGUAGE_CODE }}">
<head>
{% if IS_PRODUCTION %}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZ5QSP6QPL"></script>
<script>
window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-PZ5QSP6QPL');
</script>
{% endif %}
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>

View file

@ -13,7 +13,7 @@
<h1>Manage your domains</h2>
<p class="margin-top-4">
{% if is_production %}
{% if IS_PRODUCTION %}
<a href="javascript:void(0)"
class="usa-button usa-tooltip disabled-link"
data-position="right"

View file

@ -2,7 +2,6 @@ from django.db.models import F
from django.shortcuts import render
from registrar.models import DomainApplication
from django.conf import settings
def index(request):
@ -23,5 +22,4 @@ def index(request):
state=F("domain__state"),
)
context["domains"] = domains
context["is_production"] = settings.IS_PRODUCTION
return render(request, "home.html", context)