All Projects → beyonk-adventures → svelte-google-analytics

beyonk-adventures / svelte-google-analytics

Licence: other
Google Analytics component for Svelte

Programming Languages

javascript
184084 projects - #8 most used programming language
Svelte
593 projects
HTML
75241 projects

Projects that are alternatives of or similar to svelte-google-analytics

React Tracker
React specific tracking library, Track user interaction with minimal API!
Stars: ✭ 191 (+365.85%)
Mutual labels:  tracking, analytics, google-analytics
Aurelia Google Analytics
An Aurelia.io plugin that adds Google Analytics page tracking to your project.
Stars: ✭ 28 (-31.71%)
Mutual labels:  tracking, analytics, google-analytics
Vue Analytics
Google Analytics plugin for Vue
Stars: ✭ 1,780 (+4241.46%)
Mutual labels:  tracking, analytics, google-analytics
Php Ga Measurement Protocol
Send data to Google Analytics from the server using PHP. Implements GA measurement protocol.
Stars: ✭ 561 (+1268.29%)
Mutual labels:  tracking, analytics, google-analytics
Gumshoe
A we analytics and event tracking sleuth JavaScript library
Stars: ✭ 39 (-4.88%)
Mutual labels:  tracking, analytics, google-analytics
Vue Gtag
Global Site Tag plugin for Vue (gtag.js)
Stars: ✭ 445 (+985.37%)
Mutual labels:  tracking, analytics, google-analytics
Yett
🔐A small webpage library to control the execution of (third party) scripts
Stars: ✭ 615 (+1400%)
Mutual labels:  tracking, analytics
Mixpanel Android
Official Mixpanel Android SDK
Stars: ✭ 907 (+2112.2%)
Mutual labels:  tracking, analytics
Keen Tracking.js
A light, fast and flexible javascript tracking library
Stars: ✭ 218 (+431.71%)
Mutual labels:  tracking, analytics
gtm-guidelines
A collection of best practices for your daily Google Tag Manager routine
Stars: ✭ 39 (-4.88%)
Mutual labels:  tracking, google-analytics
vue-seo-friendly-spa-template
Vue.js PWA/SPA template initially scaffolded with vue-cli and configured for SEO. Makes use of prerendering and other techniques/packages in order to achieve a perfect "Lighthouse Score".
Stars: ✭ 41 (+0%)
Mutual labels:  google-analytics, seo
Rotki
A portfolio tracking, analytics, accounting and tax reporting application that protects your privacy
Stars: ✭ 689 (+1580.49%)
Mutual labels:  tracking, analytics
Rack Tracker
Tracking made easy: Don’t fool around with adding tracking and analytics partials to your app and concentrate on the things that matter.
Stars: ✭ 601 (+1365.85%)
Mutual labels:  tracking, google-analytics
swetrix-js
The JavaScript analytics client for Swetrix Analytics
Stars: ✭ 28 (-31.71%)
Mutual labels:  tracking, analytics
dashflare
🕵🏼‍♀️ Open Source and privacy-focused analytics solution. 📊 Advanced monitoring for your website behind Cloudflare
Stars: ✭ 78 (+90.24%)
Mutual labels:  analytics, google-analytics
viper
Real-time tracking and analytics using Node.js and Socket.IO
Stars: ✭ 12 (-70.73%)
Mutual labels:  tracking, analytics
Social-Media-Monitor
Automatically monitor and log fan counters from social media(Facebook Pages, Twitter, Instagram, YouTube, Google+, OneSignal, Alexa) using APIs to Google Spreadsheet. Very useful for website admins and social media managers.
Stars: ✭ 36 (-12.2%)
Mutual labels:  analytics, google-analytics
Blacklist
Curated and well-maintained hostfile to block ads, tracking, cryptomining, and more! Updated regularly. ⚡🔒
Stars: ✭ 492 (+1100%)
Mutual labels:  tracking, analytics
Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+11746.34%)
Mutual labels:  tracking, analytics
pageviews
A simple and lightweight pageviews counter for your WordPress posts and pages.
Stars: ✭ 23 (-43.9%)
Mutual labels:  tracking, analytics




Svelte Google Analytics

js-standard-style Svelte v3

Supports Google Analytics v4!

Install the package

npm i --save-dev @beyonk/svelte-google-analytics

Usage

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.

The 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 } }} />

The 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>

Page Tracking

With Google Analytics v4, most basic events are automatic. See the docs

(see Google Analytics offical docs - Pageviews) for more info

 

Event Tracking

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

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>

Multiple Properties

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')

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.

ga.setUserProperties({
  favorite_composer: 'Mahler',
  favorite_instrument: 'double bass',
  season_ticketholder: 'true'
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].