Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit f017b05

Browse files
committed
Session fix
1 parent a391510 commit f017b05

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ Add the directive somewhere after initializing/configuring GA. The POST request
5353
window.dataLayer = window.dataLayer || [];
5454
function gtag(){dataLayer.push(arguments);}
5555
gtag('js', new Date());
56-
gtag('config', 'UA-01234567-89');
57-
58-
@sendAnalyticsClientId
56+
gtag('config', 'UA-01234567-89', { 'send_page_view': false });
57+
gtag('event', 'page_view', { 'event_callback': function() {
58+
@sendAnalyticsClientId
59+
}});
5960
</script>
6061
```
6162

resources/views/sendCliendId.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
if(clientId != @json(app('analytics-event-tracking.client-id'))) {
55
window.axios.post('/gaid', { id: clientId });
66
}
7-
}
7+
});

src/ServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private function registerAnalytics()
9191
private function registerRoute()
9292
{
9393
if ($httpUri = config('analytics-event-tracking.http_uri')) {
94-
Route::post($httpUri, StoreClientIdInSession::class);
94+
Route::post($httpUri, StoreClientIdInSession::class)->middleware('web');
9595
}
9696
}
9797
}

tests/Http/StoreClientIdInSessionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class StoreClientIdInSessionTest extends TestCase
77
/** @test */
88
public function it_can_post_the_client_id()
99
{
10+
config(['app.key' => 'base64:xGhskOzI1x0Q0Zl+FHP55ReD33Fp7glHyh+lZyJxOtM=']);
11+
1012
$this->post('/gaid', ['id' => '1337'])
1113
->assertOk()
1214
->assertSessionHas('analytics-event-tracker-client-id', '1337');

0 commit comments

Comments
 (0)