<a href="https://beyonk.com"> <br /> <br /> <img src="https://user-images.githubusercontent.com/218949/144224348-1b3a20d5-d68e-4a7a-b6ac-6946f19f4a86.png" width="198" /> <br /> <br /> </a>
npm install @beyonk/svelte-google-analytics 
Supports Google Analytics v4!
``bash`
pnpm i --save-dev @beyonk/svelte-google-analytics
`svelte
import { GoogleAnalytics } from '@beyonk/svelte-google-analytics'
`
Component accepts two additional properties: enabled and configurations.
$3
configurations props which accepts an object type with configurations for the properties. The key in this object is the id of the property.
Example on disabling automatic pageviews for the id-1 property:`svelte
properties={[ 'id-1' ]}
configurations={{ 'id-1': { 'send_page_view': false } }} />
`$3
The enabled prop set to true by default.
Logic can be added here to disable/enable analytics.If you disable tracking by default, for instance, due to GDPR, then you can enable it later by calling
init() on your component:`svelte
bind:this={ga}
properties={[ 'id-1' ]}
enabled={false} />
`$3
With Google Analytics v4, most basic events are automatic. See the docs(see Google Analytics offical docs - Pageviews) for more info
$3
All events specified in the documentation are implemeneted (generated automatically from scraping the docs pages and building the project!)
`svelte
`#### Custom Events
Custom events can be tracked with
addEvent:`svelte
`
#### Multiple Properties
To send an event to a different property, specify the property id as the last parameter to the event:
send_to.`js
ga.games.earnVirtualCurrency('SvelteBucks', 50, 'Property Id B')
`#### Set User Properties
To split user to different segment, such as language preference or geographic location, set the Properties with
setUserProperties and setup custom dimension on Google Analytics dashboard. For more information see Google Analytics Documentation.`js
ga.setUserProperties({
favorite_composer: 'Mahler',
favorite_instrument: 'double bass',
season_ticketholder: 'true'
})
`#### Set User Id
To identify user inside GA and link their sessions together, set the Properties with
setUserId.`js
ga.setUserId('user_id_here')
`
#### Set config
To add a Google Analytics ID after initialization call the
setConfig and pass optional configuration options.`js
ga.setConfig('ga_id', opts)
``