Skip to content

Commit

Permalink
Add analytics component
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaszkadziela committed Mar 29, 2024
1 parent 486ef99 commit 2375659
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/View/Components/MainLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MainLayout extends Component
public function __construct(
public ?string $title = null,
public ?string $bodyClass = null,
public ?bool $withAnalytics = null,
public ?bool $withLanguageDropdown = null,
public ?bool $withFooter = null,
) {
Expand Down
2 changes: 2 additions & 0 deletions resources/views/components/analytics.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $gId }}"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','{{ $gId }}');</script>
1 change: 1 addition & 0 deletions resources/views/hub.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<x-main-layout title="{{ Lang::get('main.titles.hub') }}"
body-class="bg-dotted flex flex-col min-h-screen"
with-analytics
with-language-dropdown
with-footer
>
Expand Down
3 changes: 3 additions & 0 deletions resources/views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<meta property="og:url" content="{{ config('app.url') }}">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer">
@vite(['resources/css/app.css', 'resources/js/app.js'])
@if(App::isProduction() && isset($withAnalytics))
<x-analytics g-id="G-BXRVLNWTXR" />
@endif
</head>
<body class="{{ $bodyClass }}">
@isset($withLanguageDropdown)
Expand Down
1 change: 1 addition & 0 deletions resources/views/privacy.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<x-main-layout title="{{ Lang::get('main.titles.privacy') }}"
body-class="bg-dotted flex flex-col min-h-screen"
with-analytics
with-language-dropdown
with-footer
>
Expand Down

0 comments on commit 2375659

Please sign in to comment.