Skip to content

Latest commit

 

History

History

splunk

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Splunk logo

Splunk

homepage: splunk.com
docs: Splunk Collector API import: import { Angulartics2Splunk } from 'angulartics2';

Setup

  1. Add tracking code provided by Splunk to right above the </head> closing tag.
<script type="text/javascript"> var sp=sp||[];(function(){var e=["init","identify","track","trackLink","pageview"],t=function(e){return function(){sp.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var n=0;n<e.length;n++)sp[e[n]]=t(e[n])})(),sp.load=function(e,o){sp._endpoint=e;if(o){sp.init(o)};var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"===document.location.protocol?"https://":"http://")+"d21ey8j28ejz92.cloudfront.net/analytics/v1/sp.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)};
sp.load("https://www.example.com"); // Replace with your own collector URL
</script>

In the last line of above script, make sure to replace https://www.example.com with the address of your data collector.

  1. Setup Angulartics using Angulartics2Splunk.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';

import { Angulartics2Module } from 'angulartics2';

const ROUTES: Routes = [
  { path: '',      component: HomeComponent },
  { path: 'about', component: AboutComponent },
];

@NgModule({
  imports: [
    BrowserModule,
    RouterModule.forRoot(ROUTES),

    // added to imports
    Angulartics2Module.forRoot(),
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
  1. Required: Import your providers in the root component. This starts the tracking of route changes.
// component
import { Angulartics2Splunk } from 'angulartics2';

@Component({  ...  })
export class AppComponent {
  constructor(angulartics2Splunk: Angulartics2Splunk) {
    angulartics2Splunk.startTracking();
  }
}