Giter Site home page Giter Site logo

lanicon / blazor-analytics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isc30/blazor-analytics

0.0 1.0 0.0 268 KB

Blazor extensions for Analytics: Google Analytics, GTAG, ...

License: MIT License

HTML 17.33% C# 60.53% TypeScript 22.14%

blazor-analytics's Introduction

Blazor extensions for Analytics: Google Analytics, GTAG, etc...
AspNetCore Version: 3.1.8

NuGet Package

https://nuget.org/packages/Blazor-Analytics

Configuration

For Every Tracker

First, import the namespaces in _Imports.razor

@using Blazor.Analytics
@using Blazor.Analytics.Components

Then, add the NavigationTracker component below your Router in App.razor.
The tracker listens to every navigation change while it's rendered on a page.

    <Router ... />
+   <NavigationTracker />

ServerSide Specific Configuration

Edit _Host.cshtml and apply the following change:

    <script src="_framework/blazor.server.js"></script>
+   <script src="_content/Blazor-Analytics/blazor-analytics.js"></script>

WASM Specific Configuration

Edit index.html and apply the following change:

    <script src="_framework/blazor.webassembly.js"></script>
+   <script src="_content/Blazor-Analytics/blazor-analytics.js"></script>

Setting up GoogleAnalytics

Inside your main Startup/Program, call AddGoogleAnalytics. This will configure your GTAG_ID automatically.

+   services.AddGoogleAnalytics("YOUR_GTAG_ID");

How to trigger an Analytics Event

  1. Inject IAnalytics wherever you want to trigger the event.
  2. Call IAnalytics.TrackEvent passing the EventName, Value and Category (optional).

Changelog

v3.1.0

  • Support for Events

v3.0.0

  • Added support for
    • ServerSide (pre-rendering)
    • ServerSide (runtime)
    • WASM (runtime)

blazor-analytics's People

Contributors

isc30 avatar dedmen avatar dinonovak avatar enritski avatar swimburger avatar mcastellano avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.