Skip to content

Commit

Permalink
Merge pull request #53 from rzashakeri/develop
Browse files Browse the repository at this point in the history
✨ feat: Add google analytics
  • Loading branch information
rzashakeri authored Jan 6, 2024
2 parents fc3dc39 + 43b862e commit 1cda98f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@
MEDIA_ROOT = str(BASE_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = "/media/"

# GOOGLE ANALYTICS
# ------------------------------------------------------------------------------
GOOGLE_ANALYTICS_ID = env("GOOGLE_ANALYTICS_ID")
GOOGLE_ANALYTICS = {
'google_analytics_id': GOOGLE_ANALYTICS_ID,
}
11 changes: 10 additions & 1 deletion config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"ckeditor",
"admin_honeypot",
"captcha",
"google_analytics",
]

LOCAL_APPS = [
Expand Down Expand Up @@ -371,7 +372,8 @@
# SENTRY
# ------------------------------------------------------------------------------
sentry_sdk.init(
dsn=env("SENTRY_DSN", default='https://0cff28b5fc3edb790db73995bc4b9fe4@o4505345204224000.ingest.sentry.io/4506361942441984'),
dsn=env("SENTRY_DSN",
default='https://0cff28b5fc3edb790db73995bc4b9fe4@o4505345204224000.ingest.sentry.io/4506361942441984'),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
Expand All @@ -380,3 +382,10 @@
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)

# GOOGLE ANALYTICS
# ------------------------------------------------------------------------------
GOOGLE_ANALYTICS_ID = env("GOOGLE_ANALYTICS_ID")
GOOGLE_ANALYTICS = {
'google_analytics_id': GOOGLE_ANALYTICS_ID,
}
6 changes: 6 additions & 0 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = 'http://media.testserver/'

# GOOGLE ANALYTICS
# ------------------------------------------------------------------------------
GOOGLE_ANALYTICS_ID = env("GOOGLE_ANALYTICS_ID")
GOOGLE_ANALYTICS = {
'google_analytics_id': GOOGLE_ANALYTICS_ID,
}
1 change: 1 addition & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
path("", include("pages.urls")),
path("blog/", include("blog.urls")),
path('captcha/', include('captcha.urls')),
path('djga/', include('google_analytics.urls')),
# Django Admin, use {% url 'admin:index' %}
path('admin/', include('admin_honeypot.urls')),
path(ADMIN_URL, admin.site.urls),
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ django-simple-captcha==0.5.20
django-autoslug==1.9.9
coverage>=6.5.0
coveralls==3.3.1
sentry-sdk[django]==1.38.0
sentry-sdk[django]==1.38.0
django-google-analytics-app==6.0.0
5 changes: 4 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static i18n render_partial %}<!DOCTYPE html>
{% load static i18n render_partial google_analytics_tags %}<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}
<html lang="{{ LANGUAGE_CODE }}">
<head>
Expand Down Expand Up @@ -40,6 +40,9 @@
{% endfor %}
{% endif %}
{% include 'shared/header.html' %}
<div style="display:none">
<img src="{% google_analytics %}" width="0" height="0" alt=""/>
</div>
<main class="main">
<div id="wrapper">
<div id="container">
Expand Down

0 comments on commit 1cda98f

Please sign in to comment.