Skip to content

Commit

Permalink
Add google analytics 4
Browse files Browse the repository at this point in the history
  • Loading branch information
arifszn committed Aug 10, 2021
1 parent c847901 commit eb28986
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
5 changes: 3 additions & 2 deletions database/seeders/PortfolioSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Services\Contracts\ServiceInterface;
use App\Services\Contracts\SkillInterface;
use App\Services\Contracts\VisitorInterface;
use Config;
use Illuminate\Database\Seeder;
use Log;
use Str;
Expand Down Expand Up @@ -60,8 +61,8 @@ public function run()
//google analytics ID
$data = [
'setting_key' => CoreConstants::PORTFOLIO_CONFIG__GOOGLE_ANALYTICS_ID,
'setting_value' => '',
'default_value' => '',
'setting_value' => Config::get('custom.demo_mode') ? 'G-PS8JF33VLD' : '',
'default_value' => Config::get('custom.demo_mode') ? 'G-PS8JF33VLD' : '',
];
$portfolioConfig->insertOrUpdate($data);

Expand Down
11 changes: 11 additions & 0 deletions resources/views/common/googleAnalytics.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@if (!empty($portfolioConfig['googleAnalyticsId']) && $portfolioConfig['googleAnalyticsId'] != '')
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src={{"https://www.googletagmanager.com/gtag/js?id=".$portfolioConfig['googleAnalyticsId']}}></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{$portfolioConfig["googleAnalyticsId"]}}');
</script>
@endif
13 changes: 1 addition & 12 deletions resources/views/frontend/theme/procyon.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
@if (!empty($portfolioConfig['googleAnalyticsId']) && $portfolioConfig['googleAnalyticsId'] != '')
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src={{"https://www.googletagmanager.com/gtag/js?id=".$portfolioConfig['googleAnalyticsId']}}></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{$portfolioConfig["googleAnalyticsId"]}}');
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
@endif
@include('common.googleAnalytics')
@if (!empty($portfolioConfig['script']['header']) && $portfolioConfig['script']['header'] != '')
<script>
{!!$portfolioConfig['script']['header']!!}
Expand Down
13 changes: 1 addition & 12 deletions resources/views/frontend/theme/rigel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
@if (!empty($portfolioConfig['googleAnalyticsId']) && $portfolioConfig['googleAnalyticsId'] != '')
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src={{"https://www.googletagmanager.com/gtag/js?id=".$portfolioConfig['googleAnalyticsId']}}></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{$portfolioConfig["googleAnalyticsId"]}}');
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
@endif
@include('common.googleAnalytics')
@if (!empty($portfolioConfig['script']['header']) && $portfolioConfig['script']['header'] != '')
<script>
{!!$portfolioConfig['script']['header']!!}
Expand Down
13 changes: 1 addition & 12 deletions resources/views/frontend/theme/vega.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
@if (!empty($portfolioConfig['googleAnalyticsId']) && $portfolioConfig['googleAnalyticsId'] != '')
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src={{"https://www.googletagmanager.com/gtag/js?id=".$portfolioConfig['googleAnalyticsId']}}></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{$portfolioConfig["googleAnalyticsId"]}}');
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
@endif
@include('common.googleAnalytics')
@if (!empty($portfolioConfig['script']['header']) && $portfolioConfig['script']['header'] != '')
<script>
{!!$portfolioConfig['script']['header']!!}
Expand Down

0 comments on commit eb28986

Please sign in to comment.