generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create config * Create identify component * Update instructions
- Loading branch information
1 parent
bff252e
commit 158720c
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,16 +40,38 @@ php artisan vendor:publish --tag="clarity-views" | |
|
||
## Usage | ||
|
||
### General Tracking | ||
|
||
- Create an account: The first thing you need to do is create an account on Microsoft Clarity. You can sign up on their website and follow the steps to create your account. Then, get your tracking code and that's it. | ||
- Simply add the blade components to your base layout files. | ||
|
||
The `enabled` attribute is optional, but can be used to control the tags integration from blade files that extend the base layout. It accepts `true/false`. | ||
The `enabled` attribute is *optional*, but can be used to control the tags integration from blade files that extend the base layout. It accepts `true/false`. | ||
This can still be controlled globally via the `.env` file should you need to disable the integration global on different environments as well. | ||
|
||
```html | ||
<!-- Should be placed in the head --> | ||
<x-clarity::script :enabled="$enabled" /> | ||
``` | ||
### Identify API | ||
|
||
To implement the [Identify API](https://learn.microsoft.com/en-us/clarity/setup-and-installation/identify-api), use `identify` component. | ||
Set `CLARITY_IDENTIFICATION_ENABLED` value to `true` on the env file. | ||
|
||
#### Attributes: | ||
* `user` attribute is *required* accepts the User Model instance or any object. The `email` and `name` attributes are used. | ||
* `enabled` attribute is *optional*. | ||
* `custom_session_id` attribute is *optional*. | ||
* `custom_page_id` attribute is *optional*. | ||
|
||
```html | ||
@auth | ||
<x-clarity::identify :user="request()->user()"/> | ||
@endauth | ||
``` | ||
This will compile as: | ||
```js | ||
window.clarity("identify", "[email protected]", null, null, "Username") | ||
``` | ||
|
||
## Testing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@props([ | ||
'enabled' => true, | ||
'user' => null, | ||
'custom_session_id' => null, | ||
'custom_page_id' => null, | ||
]) | ||
|
||
@if ($enabled && config('clarity.enabled') && config('clarity.enabled_identify_api')) | ||
<script type="text/javascript"> | ||
(function(){ | ||
window.clarity( | ||
"identify", | ||
@if($user?->email) "{{$user->email}}" @else null @endif, | ||
@if($custom_session_id) "{{$custom_session_id}}" @else null @endif, | ||
@if($custom_page_id) "{{$custom_page_id}}" @else null @endif, | ||
@if($user?->name) "{{$user->name}}" @else null @endif, | ||
); | ||
})(); | ||
</script> | ||
@endif |