From fc1d58bb54e3b9665056e0ae9e620fbe5ac7f3d1 Mon Sep 17 00:00:00 2001 From: brentryanjohnson Date: Wed, 30 Jan 2019 15:55:37 -0800 Subject: [PATCH 1/2] Attempts to fix analytics by abandoning plugin and hardcoding into react helmet --- blog-site/gatsby-config.js | 1 + blog-site/src/pages/index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/blog-site/gatsby-config.js b/blog-site/gatsby-config.js index a9fba52b7..61c3ceb51 100644 --- a/blog-site/gatsby-config.js +++ b/blog-site/gatsby-config.js @@ -14,6 +14,7 @@ module.exports = { author: 'Ryan Johnson', description: 'Our blog about data, design, and innovation at the Department of the Interior', siteUrl: 'https://revenuedata.doi.gov/', + googleAnalyticsId: GOOGLE_ANALYTICS_ID, }, pathPrefix: `${BASEURL}/blog`, mapping: { diff --git a/blog-site/src/pages/index.js b/blog-site/src/pages/index.js index 9cc4a4625..d97443aa4 100644 --- a/blog-site/src/pages/index.js +++ b/blog-site/src/pages/index.js @@ -14,6 +14,7 @@ class BlogIndex extends React.Component { this, 'props.data.site.siteMetadata.description' ) + const siteAnalytics = get(this, 'props.data.site.siteMetadata.googleAnalyticsId') const posts = get(this, 'props.data.allMarkdownRemark.edges') return ( @@ -23,7 +24,16 @@ class BlogIndex extends React.Component { meta={[{ name: 'description', content: siteDescription }]} title={siteTitle} link={[{ rel: 'shortcut icon', type: 'image/png', href: `${favicon}` }]} - /> + > + {/* Digital Analytics Program roll-up, see the data at https://analytics.usa.gov */} + + {siteAnalytics && + + } + + {posts.map(({ node }) => { const title = get(node, 'frontmatter.title') || node.fields.slug return ( @@ -72,6 +82,7 @@ export const pageQuery = graphql` siteMetadata { title description + googleAnalyticsId } } allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) { From 5c9a7c37dc126153624f8876e80b65d0db1131ff Mon Sep 17 00:00:00 2001 From: brentryanjohnson Date: Wed, 30 Jan 2019 16:46:39 -0800 Subject: [PATCH 2/2] Adds helmet to blog post layout --- blog-site/src/templates/blog-post.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/blog-site/src/templates/blog-post.js b/blog-site/src/templates/blog-post.js index 1c7965bbc..098a8222a 100644 --- a/blog-site/src/templates/blog-post.js +++ b/blog-site/src/templates/blog-post.js @@ -8,6 +8,7 @@ import { rhythm, scale } from '../utils/typography' class BlogPostTemplate extends React.Component { render() { + const siteAnalytics = get(this.props, 'data.site.siteMetadata.googleAnalyticsId') const post = this.props.data.markdownRemark const siteTitle = get(this.props, 'data.site.siteMetadata.title') const siteDescription = post.excerpt @@ -19,7 +20,16 @@ class BlogPostTemplate extends React.Component { htmlAttributes={{ lang: 'en' }} meta={[{ name: 'description', content: siteDescription }]} title={`${post.frontmatter.title} | ${siteTitle}`} - /> + > + {/* Digital Analytics Program roll-up, see the data at https://analytics.usa.gov */} + + {siteAnalytics && + + } + +