我已经花了将近4-5个小时的时间来解决这个问题,但是我做不到……但是幸运的是,我的盖茨比APP成功地承认了Google Analytics(分析)。
但是,问题发生了来自Google Tag Assistant
Chrome扩展程序的“未检测到HTTP响应”。
我已经多次将Google Analytics(分析)摘要粘贴到HTML.js
,Index.html
中,并且也更新了最新版本的GatsbyJs。
此外,我也尝试关闭了Adblock
扩展名!但都失败了...
gatsby-config.js
module.exports = {
// Note: it must *not* have a trailing slash.
siteMetadata: {
title: 'SJ personal Blog',
siteUrl: `https://ollagada.github.io`
},
plugins: [
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: "MY TRACKING ID",
// Puts tracking script in the head instead of the body
head: true,
// Setting this parameter is optional
anonymize: true,
// Setting this parameter is also optional
respectDNT: true,
// Avoids sending pageview hits from custom paths
exclude: ["/preview/**", "/do-not-track/me/too/"],
// Enables Google Optimize using your container Id
optimizeId: "YOUR_GOOGLE_OPTIMIZE_TRACKING_ID",
// Any additional create only fields (optional)
sampleRate: 5,
siteSpeedSampleRate: 10,
},
},
{
resolve: `gatsby-plugin-gtag`,
options: {
// your google analytics tracking id
trackingId: `MY TRACKING ID`,
// Puts tracking script in the head instead of the body
head: true,
// enable ip anonymization
anonymize: true,
},
},
'gatsby-transformer-remark', {
resolve: `gatsby-source-filesystem`,
options: {
name: `posts`,
path: `${__dirname}/src/pages/posts`
}
},
'gatsby-plugin-react-helmet', {
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/img/moi.jpg', // This path is relative to the root of the site.
}
},
]
Package.json
{
"name": "gatsby-starter-default",
"description": "Gatsby default starter",
"version": "1.0.0",
"author": "Kyle Mathews ",
"dependencies": {
"aos": "^2.3.4",
"child_process": "^1.0.2",
"fs": "0.0.1-security",
"gatsby": "^2.0.75",
"gatsby-plugin-google-analytics": "^2.0.8",
"gatsby-plugin-gtag": "^1.0.4",
"gatsby-plugin-manifest": "^2.0.2",
"gatsby-plugin-offline": "^2.0.5",
"gatsby-plugin-react-helmet": "^3.0.0",
"gatsby-plugin-sharp": "^2.0.5",
"gatsby-source-filesystem": "^2.0.1",
"gatsby-transformer-remark": "^2.1.17",
"gatsby-transformer-sharp": "^2.1.1",
"instafeed.js": "^1.4.1",
"net": "^1.0.2",
"prop-types": "^15.6.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-helmet": "^5.2.0",
"react-instafeed": "^0.4.0",
"react-lines-ellipsis": "^0.13.2",
"react-mdl": "^1.11.0",
"react-spinkit": "^3.0.0",
"tls": "0.0.1",
"typed.js": "^2.0.9",
"window": "^4.2.5"
},
"keywords": [
"gatsby"
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write '**/*.js'",
"test": "echo \"Error: no test specified\" && exit 1",
"deploy": "gatsby build --prefix-paths && gh-pages -b master -d public"
},
"devDependencies": {
"gh-pages": "^2.0.0",
"prettier": "^1.14.2"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
}
}
谢谢!可爱的一天!