Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@beyonk/svelte-google-analytics
Advanced tools
Supports Google Analytics v4!
pnpm i --save-dev @beyonk/svelte-google-analytics
In App.svelte
import { GoogleAnalytics } from '@beyonk/svelte-google-analytics'
<GoogleAnalytics properties={[ 'google property id A', ...'google property id X' ]} />
Component accepts two additional properties: enabled
and configurations
.
configurations
property (optional)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:
<GoogleAnalytics
properties={[ 'id-1' ]}
configurations={{ 'id-1': { 'send_page_view': false } }} />
enabled
property (optional)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:
<GoogleAnalytics
bind:this={ga}
properties={[ 'id-1' ]}
enabled={false} />
<script>
function enableAnalytics () {
ga.init()
}
</script>
With Google Analytics v4, most basic events are automatic. See the docs
(see Google Analytics offical docs - Pageviews) for more info
All events specified in the documentation are implemeneted (generated automatically from scraping the docs pages and building the project!)
<script>
import { ga } from '@beyonk/svelte-google-analytics'
function handleClick () {
ga.games.earnVirtualCurrency('SvelteBucks', 50)
}
</script>
<main>
<button on:click={handleClick}>Get 50 SvelteBucks</button>
</main>
Custom events can be tracked with addEvent
:
<script>
import { ga } from '@beyonk/svelte-google-analytics'
function handleClick () {
ga.addEvent('event_name', {
foo: 'bar',
baz: 'qux'
})
}
</script>
To send an event to a different property, specify the property id as the last parameter to the event: send_to
.
ga.games.earnVirtualCurrency('SvelteBucks', 50, 'Property Id B')
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.
ga.setUserProperties({
favorite_composer: 'Mahler',
favorite_instrument: 'double bass',
season_ticketholder: 'true'
})
To identify user inside GA and link their sessions together, set the Properties with setUserId
.
ga.setUserId('user_id_here')
To add a Google Analytics ID after initialization call the setConfig
and pass optional configuration options.
ga.setConfig('ga_id', opts)
FAQs
Unknown package
The npm package @beyonk/svelte-google-analytics receives a total of 0 weekly downloads. As such, @beyonk/svelte-google-analytics popularity was classified as not popular.
We found that @beyonk/svelte-google-analytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.