From b210da65c56fa0938e62d87f757751862377794f Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Wed, 12 Aug 2020 17:13:57 -0400 Subject: [PATCH] Track link clicks in code --- src/app/contact/contact.component.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts index a0c6425..6f7ba30 100644 --- a/src/app/contact/contact.component.ts +++ b/src/app/contact/contact.component.ts @@ -1,4 +1,5 @@ import {AfterContentInit, Component, OnInit} from '@angular/core'; +import { Angulartics2 } from 'angulartics2'; @Component({ selector: 'app-contact', @@ -7,21 +8,34 @@ import {AfterContentInit, Component, OnInit} from '@angular/core'; }) export class ContactComponent implements AfterContentInit { - constructor() { + constructor(private analytics: Angulartics2) { } ngAfterContentInit(): void { } linkedInClicked() { + this.analytics.eventTrack.next(this.linkClickEvent('LinkedIn')); window.open('https://www.linkedin.com/in/cameron-cordes-3b166583/'); } githubClicked() { + this.analytics.eventTrack.next(this.linkClickEvent('GitHub')); window.open('https://github.com/Stampede10343'); } emailClicked() { + this.analytics.eventTrack.next(this.linkClickEvent('Email')); window.open('mailto:cameronc.dev@gmail.com'); } + + private linkClickEvent(label: String): object { + return { + action: 'LinkClick', + properties: { + category: 'Contact', + label: label + } + } + } }