Attempt to fix no ga code in www. sites
This commit is contained in:
		
					parent
					
						
							
								63635f158e
							
						
					
				
			
			
				commit
				
					
						01b64fec88
					
				
			
		
					 1 changed files with 7 additions and 1 deletions
				
			
		|  | @ -7,7 +7,13 @@ def google_analytics(request): | ||||||
|     render your Google Analytics tracking code template. |     render your Google Analytics tracking code template. | ||||||
|     """ |     """ | ||||||
|     host = request.get_host() |     host = request.get_host() | ||||||
|     ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(host) |     ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get( | ||||||
|  |         host) | ||||||
|  |     if ga_prop_id is None: | ||||||
|  |         # Try checking if we have a www in host, if yes we remove | ||||||
|  |         # that and check in the dict again | ||||||
|  |         if host.startswith('www.'): | ||||||
|  |             ga_prop_id = host[4:] | ||||||
|     if not settings.DEBUG and ga_prop_id: |     if not settings.DEBUG and ga_prop_id: | ||||||
|         return { |         return { | ||||||
|             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id |             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue