Skip to content

Commit 1d088c1

Browse files
committed
add ga-analytics
1 parent f5ede65 commit 1d088c1

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ ROLES_GUI_FLASH_MESSAGES_ENABLED=false
147147
ROLES_GUI_BLADE_PLACEMENT_CSS=template_linked_css
148148
ROLES_GUI_BLADE_PLACEMENT_JS=footer_scripts
149149

150+
# Google Analytics - If blank it will not render, default is false
151+
GOOGLE_ANALYTICS_ID=
152+
#GOOGLE_ANALYTICS_ID='UA-XXXXXXXX-X'
153+
150154
# NOTE: YOU CAN REMOVE THE KEY CALL IN app.blade.php IF YOU GET A POP UP AND DO NOT WANT TO SETUP A KEY FOR DEV
151155
# Google Maps API v3 Key - https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
152156
GOOGLEMAPS_API_STATUS=true

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ php artisan vendor:publish --tag=laravel2step
191191

192192
### Routes
193193

194-
```
194+
```bash
195195
+--------+----------------------------------------+---------------------------------------+-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------+
196196
| Domain | Method | URI | Name | Action | Middleware |
197197
+--------+----------------------------------------+---------------------------------------+-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------+
@@ -525,6 +525,10 @@ ROLES_GUI_FLASH_MESSAGES_ENABLED=false
525525
ROLES_GUI_BLADE_PLACEMENT_CSS=template_linked_css
526526
ROLES_GUI_BLADE_PLACEMENT_JS=footer_scripts
527527
528+
# Google Analytics
529+
GOOGLE_ANALYTICS_ID=
530+
#GOOGLE_ANALYTICS_ID='UA-XXXXXXXX-X'
531+
528532
# NOTE: YOU CAN REMOVE THE KEY CALL IN app.blade.php IF YOU GET A POP UP AND DO NOT WANT TO SETUP A KEY FOR DEV
529533
# Google Maps API v3 Key - https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
530534
GOOGLEMAPS_API_STATUS=true

config/settings.php

+5
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@
7676
* DropZone CDN
7777
*/
7878
'dropZoneJsCDN' => env('DROPZONE_JS_CDN', 'https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/dropzone.js'),
79+
80+
/*
81+
* Google Analytics
82+
*/
83+
'googleanalyticsId' => env('GOOGLE_ANALYTICS_ID', false),
7984
];

resources/views/layouts/app.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
@endif
5252

5353
@yield('head')
54-
54+
@include('scripts.ga-analytics')
5555
</head>
5656
<body>
5757
<div id="app">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@if(config('settings.googleanalyticsId'))
2+
<!-- Global site tag (gtag.js) - Google Analytics -->
3+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-38926236-1"></script>
4+
<script>
5+
window.dataLayer = window.dataLayer || [];
6+
function gtag(){dataLayer.push(arguments);}
7+
gtag('js', new Date());
8+
9+
gtag('config', '{{ config('settings.googleanalyticsId') }}');
10+
</script>
11+
@endif

resources/views/welcome.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
margin-bottom: 30px;
6767
}
6868
</style>
69+
@include('scripts.ga-analytics')
6970
</head>
7071
<body>
7172
<div class="flex-center position-ref full-height">

0 commit comments

Comments
 (0)