Add GOOGLE_ANALYTICS_PROPERTY_IDS for dynamic set ID
This commit is contained in:
		
					parent
					
						
							
								007fc794c3
							
						
					
				
			
			
				commit
				
					
						2ad984504c
					
				
			
		
					 5 changed files with 18 additions and 18 deletions
				
			
		|  | @ -33,6 +33,9 @@ | ||||||
|         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> |         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> | ||||||
|         <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> |         <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> | ||||||
|     <![endif]--> |     <![endif]--> | ||||||
|  |     <!-- Google analytics --> | ||||||
|  |     {% include "google_analytics.html" %} | ||||||
|  |     <!-- End Google Analytics --> | ||||||
| </head> | </head> | ||||||
| 
 | 
 | ||||||
| <body> | <body> | ||||||
|  | @ -47,9 +50,6 @@ | ||||||
| 	{% include "datacenterlight/includes/_footer.html" %} | 	{% include "datacenterlight/includes/_footer.html" %} | ||||||
|     <!-- Footer --> |     <!-- Footer --> | ||||||
| 
 | 
 | ||||||
|     <!-- Google analytics --> |  | ||||||
|     {% include "datacenterlight/includes/_google_analytics.html" %} |  | ||||||
| 
 |  | ||||||
|     <!-- jQuery --> |     <!-- jQuery --> | ||||||
|     <script src="{% static 'datacenterlight/js/jquery.js' %}"></script> |     <script src="{% static 'datacenterlight/js/jquery.js' %}"></script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ | ||||||
| {% load staticfiles bootstrap3 %} | {% load staticfiles bootstrap3 %} | ||||||
| {% load i18n %} | {% load i18n %} | ||||||
| {% block content %} | {% block content %} | ||||||
| {% include 'datacenterlight/includes/_google_analytics.html' %} |  | ||||||
| <div class="order-detail-container"> | <div class="order-detail-container"> | ||||||
|    {% if messages %} |    {% if messages %} | ||||||
|     <div class="row"> |     <div class="row"> | ||||||
|  |  | ||||||
|  | @ -138,6 +138,7 @@ TEMPLATES = [ | ||||||
|     { |     { | ||||||
|         'BACKEND': 'django.template.backends.django.DjangoTemplates', |         'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||||||
|         'DIRS': [os.path.join(PROJECT_DIR, 'cms_templates/'), |         'DIRS': [os.path.join(PROJECT_DIR, 'cms_templates/'), | ||||||
|  |                  os.path.join(PROJECT_DIR, 'templates'), | ||||||
|                  os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'), |                  os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'), | ||||||
|                  os.path.join(PROJECT_DIR, 'membership'), |                  os.path.join(PROJECT_DIR, 'membership'), | ||||||
|                  os.path.join(PROJECT_DIR, 'hosting/templates/'), |                  os.path.join(PROJECT_DIR, 'hosting/templates/'), | ||||||
|  | @ -161,7 +162,7 @@ TEMPLATES = [ | ||||||
|                 "django.contrib.messages.context_processors.messages", |                 "django.contrib.messages.context_processors.messages", | ||||||
|                 'sekizai.context_processors.sekizai', |                 'sekizai.context_processors.sekizai', | ||||||
|                 'cms.context_processors.cms_settings', |                 'cms.context_processors.cms_settings', | ||||||
|                 'datacenterlight.context_processor.google_analytics', |                 'utils.context_processor.google_analytics', | ||||||
|             ], |             ], | ||||||
|         }, |         }, | ||||||
|     }, |     }, | ||||||
|  | @ -512,5 +513,7 @@ DCL_TEXT = env('DCL_TEXT') | ||||||
| DCL_SUPPORT_FROM_ADDRESS = env('DCL_SUPPORT_FROM_ADDRESS') | DCL_SUPPORT_FROM_ADDRESS = env('DCL_SUPPORT_FROM_ADDRESS') | ||||||
| 
 | 
 | ||||||
| # Settings for Google analytics | # Settings for Google analytics | ||||||
| GOOGLE_ANALYTICS_PROPERTY_ID = 'UA-62285904-9' | GOOGLE_ANALYTICS_PROPERTY_IDS = { | ||||||
| GOOGLE_ANALYTICS_DOMAIN = 'auto' |     'datacenterlight.ch': 'UA-62285904-9', | ||||||
|  |     'digitalglarus.ch': 'UA-62285904-2' | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| <!-- Google Analytics --> |  | ||||||
| {% if GOOGLE_ANALYTICS_PROPERTY_ID %} | {% if GOOGLE_ANALYTICS_PROPERTY_ID %} | ||||||
|     <script> |     <script> | ||||||
|         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||||||
|  | @ -6,10 +5,9 @@ | ||||||
|         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||||||
|         })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |         })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||||||
| 
 | 
 | ||||||
|         ga('create', '{{ GOOGLE_ANALYTICS_PROPERTY_ID }}', '{{ GOOGLE_ANALYTICS_DOMAIN }}'); |         ga('create', '{{ GOOGLE_ANALYTICS_PROPERTY_ID }}', 'auto'); | ||||||
|         ga('send', 'pageview'); |         ga('send', 'pageview'); | ||||||
|     </script> |     </script> | ||||||
| {% else %} | {% else %} | ||||||
|     <!-- Empty analytics --> |     <!-- Empty analytics --> | ||||||
| {% endif %} | {% endif %} | ||||||
| <!-- End Google Analytics --> |  | ||||||
|  | @ -6,11 +6,11 @@ def google_analytics(request): | ||||||
|     Use the variables returned in this function to |     Use the variables returned in this function to | ||||||
|     render your Google Analytics tracking code template. |     render your Google Analytics tracking code template. | ||||||
|     """ |     """ | ||||||
|     ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_ID', False) |     host = request.get_host() | ||||||
|     ga_domain = getattr(settings, 'GOOGLE_ANALYTICS_DOMAIN', False) |     ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(host) | ||||||
|     if not settings.DEBUG and ga_prop_id and ga_domain: |     print(ga_prop_id) | ||||||
|  |     if ga_prop_id: | ||||||
|         return { |         return { | ||||||
|             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id, |             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id | ||||||
|             'GOOGLE_ANALYTICS_DOMAIN': ga_domain, |  | ||||||
|         } |         } | ||||||
|     return {} |     return {} | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue