diff --git a/README.md b/README.md index bc31697..abd9ba1 100644 --- a/README.md +++ b/README.md @@ -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 ``` +### 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 + +@endauth +``` +This will compile as: +```js +window.clarity("identify", "user@example.com", null, null, "Username") +``` ## Testing diff --git a/config/clarity.php b/config/clarity.php index 17494db..bf51395 100644 --- a/config/clarity.php +++ b/config/clarity.php @@ -3,4 +3,5 @@ return [ 'id' => env('CLARITY_ID', 'XXXXXX'), 'enabled' => env('CLARITY_ENABLED', true), + 'enabled_identify_api' => env('CLARITY_IDENTIFICATION_ENABLED', false), ]; diff --git a/resources/views/components/identify.blade.php b/resources/views/components/identify.blade.php new file mode 100644 index 0000000..8579d20 --- /dev/null +++ b/resources/views/components/identify.blade.php @@ -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')) + +@endif