Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soenneker/soenneker.blazor.google.analytics
A Blazor interop library for Google Analytics
https://github.com/soenneker/soenneker.blazor.google.analytics
analytics blazor csharp dotnet google googleanalyticsinterop interop
Last synced: 3 months ago
JSON representation
A Blazor interop library for Google Analytics
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.blazor.google.analytics
- Owner: soenneker
- License: mit
- Created: 2024-07-06T17:31:18.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-01T06:11:06.000Z (4 months ago)
- Last Synced: 2024-10-01T07:20:15.318Z (4 months ago)
- Topics: analytics, blazor, csharp, dotnet, google, googleanalyticsinterop, interop
- Language: C#
- Homepage: https://soenneker.com
- Size: 203 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![](https://img.shields.io/nuget/v/soenneker.blazor.google.analytics.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.google.analytics/)
[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.google.analytics/publish-package.yml?style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.google.analytics/actions/workflows/publish-package.yml)
[![](https://img.shields.io/nuget/dt/soenneker.blazor.google.analytics.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.google.analytics/)# ![](https://user-images.githubusercontent.com/4441470/224455560-91ed3ee7-f510-4041-a8d2-3fc093025112.png) Soenneker.Blazor.Google.Analytics
### A Blazor interop library for Google Analytics## Installation
```
dotnet add package Soenneker.Blazor.Google.Analytics
```## Usage
1. Register the interop within DI (`Program.cs`)
```csharp
public static async Task Main(string[] args)
{
...
builder.Services.AddGoogleAnalyticsInterop();
}
```2. Inject `IGoogleAnalyticsInterop` within your `App.Razor` file
```csharp
@using Soenneker.Blazor.Google.Analytics.Abstract
@inject IGoogleAnalyticsInterop GoogleAnalyticsInterop
```3. Initialize the interop in `OnInitializedAsync` within `App.Razor` using your Google Analytics tag id
```csharp
protected override async Task OnInitializedAsync()
{
await GoogleAnalyticsInterop.Init("your-key-here");
...
}
```