Skip to content

Commit 8174a33

Browse files
authored
Merge pull request linode#282 from hzoppetti/header-footer-10132020
[Update] Header - feature links now with GA
2 parents ec76c60 + c688939 commit 8174a33

File tree

8 files changed

+55
-0
lines changed

8 files changed

+55
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"react": "^16.7.0",
3434
"react-clipboard.js": "^2.0.7",
3535
"react-dom": "^16.7.0",
36+
"react-ga": "^3.1.2",
3637
"react-helmet": "^5.2.0",
3738
"react-markdown": "^4.0.8",
3839
"react-select": "^2.4.2",

src/components/2_molecules/navigation/communityFeatured.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { Event } from "../tracking";
23

34
const styles = {
45
color: '#ffffff'
@@ -12,6 +13,9 @@ const CommunityFeaturedNav = () => (
1213
className="c-featured"
1314
href="https://www.linode.com/marketplace/apps/linode/nextcloud/"
1415
style={styles}
16+
onClick={()=>
17+
Event('Navigation','click','nextcloud')
18+
}
1519
>
1620
<img
1721
width="632"

src/components/2_molecules/navigation/pricingFeatured.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from "react";
2+
import { Event } from "../tracking";
3+
24
const styles = {
35
borderWidth: 2,
46
borderColor: '#ededf4'
@@ -12,6 +14,9 @@ const PricingFeaturedNav = () => (
1214
className="c-featured"
1315
href="https://www.linode.com/lp/tco-calculator/"
1416
style={styles}
17+
onClick={()=>
18+
Event('Navigation','click','TCO')
19+
}
1520
>
1621
<img
1722
width="416"

src/components/2_molecules/navigation/primaryNav.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import { StaticQuery, graphql } from "gatsby";
3+
import {PageView, initGA} from "../tracking";
34

45
class MainSiteNav extends React.Component {
56
constructor(props) {
@@ -27,6 +28,9 @@ class MainSiteNav extends React.Component {
2728
const header = document.getElementById("menu-header-primary");
2829
const mobileMenu = document.getElementById("o-menu__link--mobile");
2930

31+
initGA(['UA-177150-1', 'UA-177150-30']);
32+
PageView();
33+
3034
const hideAll = () => {
3135
Object.keys(subMenus).map(d => {
3236
const em = subMenus[d];
@@ -79,6 +83,7 @@ class MainSiteNav extends React.Component {
7983
});
8084
}
8185

86+
8287
header.addEventListener("click", e => {
8388
const otherMenus = document.getElementsByClassName("c-sub-menu");
8489
const target = e.target.getAttribute("data-submenu");

src/components/2_molecules/navigation/productsFeatured.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from "react";
2+
import { Event } from "../tracking";
3+
24
const styles1 = {
35
borderWidth: 2,
46
borderColor: '#ededf4'
@@ -20,6 +22,9 @@ const ProductsFeaturedNav = () => (
2022
className="c-featured"
2123
href="https://www.linode.com/products/gpu/"
2224
style={styles1}
25+
onClick={()=>
26+
Event('Navigation','click','gpus-mumbai')
27+
}
2328
>
2429
<img
2530
width="400"

src/components/2_molecules/navigation/whyFeatured.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { Event } from "../tracking";
23

34
const styles = {
45
color: '#ffffff'
@@ -12,6 +13,9 @@ const WhyFeaturedNav = () => (
1213
className="c-featured"
1314
href="https://www.linode.com/spotlight/cloudnet/"
1415
style={styles}
16+
onClick={()=>
17+
Event('Navigation','click','cloudnet')
18+
}
1519
>
1620
<img
1721
width="632"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import ReactGA from "react-ga";
2+
3+
export const initGA = (trackingIDs) => {
4+
{trackingIDs.map(id => (
5+
ReactGA.initialize(id)
6+
))}
7+
}
8+
9+
export const PageView = () => {
10+
ReactGA.pageview(window.location.pathname +
11+
window.location.search);
12+
}
13+
14+
/**
15+
* Event - Add custom tracking event.
16+
* @param {string} category
17+
* @param {string} action
18+
* @param {string} label
19+
*/
20+
export const Event = (category, action, label) => {
21+
ReactGA.event({
22+
category: category,
23+
action: action,
24+
label: label
25+
});
26+
};

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13608,6 +13608,11 @@ react-frame-component@^4.1.0:
1360813608
resolved "https://registry.yarnpkg.com/react-frame-component/-/react-frame-component-4.1.0.tgz#bef04039c6af687314f27b20ef9893d85eefe3e6"
1360913609
integrity sha512-2HkO0iccSjd+xRA+aOxq7Mm50WUmCjdmhbQhOiG6gQTChaW//Y3mdkGeUfVA3YkXvDVbigRDvJd/VTUlqaZWSw==
1361013610

13611+
react-ga@^3.1.2:
13612+
version "3.1.2"
13613+
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.1.2.tgz#e13f211c51a2e5c401ea69cf094b9501fe3c51ce"
13614+
integrity sha512-OJrMqaHEHbodm+XsnjA6ISBEHTwvpFrxco65mctzl/v3CASMSLSyUkFqz9yYrPDKGBUfNQzKCjuMJwctjlWBbw==
13615+
1361113616
react-helmet@^5.2.0:
1361213617
version "5.2.1"
1361313618
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.1.tgz#16a7192fdd09951f8e0fe22ffccbf9bb3e591ffa"

0 commit comments

Comments
 (0)