@@ -10,15 +10,15 @@ https://nuget.org/packages/Blazor-Analytics
1010
1111First, import the namespaces in ` _Imports.razor `
1212
13- ```
13+ ``` csharp
1414@using Blazor .Analytics
1515@using Blazor .Analytics .Components
1616```
1717
1818Then, add the ` NavigationTracker ` component below your Router in ` App.razor ` .<br />
1919The tracker listens to every navigation change while it's rendered on a page.
2020
21- ``` diff
21+ ``` csharp diff
2222 < Router .. . / >
2323+ < NavigationTracker / >
2424```
@@ -27,7 +27,7 @@ The tracker listens to every navigation change while it's rendered on a page.
2727
2828Edit ` _Host.cshtml ` and apply the following change:
2929
30- ``` diff
30+ ``` html diff
3131 <script src =" _framework/blazor.server.js" ></script >
3232+ <script src =" _content/Blazor-Analytics/blazor-analytics.js" ></script >
3333```
@@ -36,7 +36,7 @@ Edit `_Host.cshtml` and apply the following change:
3636
3737Edit ` index.html ` and apply the following change:
3838
39- ``` diff
39+ ``` html diff
4040 <script src =" _framework/blazor.webassembly.js" ></script >
4141+ <script src =" _content/Blazor-Analytics/blazor-analytics.js" ></script >
4242```
@@ -45,7 +45,7 @@ Edit `index.html` and apply the following change:
4545
4646Inside your main ` Startup ` /` Program ` , call ` AddGoogleAnalytics ` . This will configure your GTAG_ID automatically.
4747
48- ``` diff
48+ ``` csharp diff
4949+ services .AddGoogleAnalytics (" YOUR_GTAG_ID" );
5050```
5151
@@ -56,7 +56,7 @@ Inside your main `Startup`/`Program`, call `AddGoogleAnalytics`. This will confi
5656<br >Or<br >
5757 Call ` IAnalytics.TrackEvent ` passing the ` EventName ` , ` Value ` and ` Category ` (optional).
5858
59- ```
59+ ``` csharp
6060@inject Blazor .Analytics .IAnalytics Analytics
6161
6262Analytics .TrackEvent (" generate_lead" , new {currency = " USD" , value = 99 . 99 });
@@ -66,20 +66,33 @@ Analytics.TrackEvent("generate_lead", new {currency = "USD", value = 99.99});
6666
67671.- Inject ITrackingState on blazor component
6868
69- ```
69+ ``` csharp
7070@using Blazor .Analytics .Abstractions
71- @inject ITrackingState DisableNavigation
71+ @using Blazor .Analytics
72+
73+ @inject ITrackingNavigationState TrackingNavigationState
74+ @inject IAnalytics GlobalTracking
7275```
7376
74772.- Disable tracking on initialized
75- ```
78+ 2.1 For current page
79+ ``` csharp
7680protected override void OnInitialized ()
7781{
7882 DisableNavigation .DisableTracking ();
7983}
8084```
85+ 2.2 For whole application
86+ ``` csharp
87+ protected override void OnInitialized ()
88+ {
89+ GlobalTracking .Disable ();
90+ }
91+ ```
8192
8293# Changelog
94+ ### v3.7.1
95+ - Support for globally enable/disable tracking for the whole application
8396### v3.7.0
8497- Support for disable tracking on any page
8598### v3.1.0
0 commit comments