google-analytics - 让 Google 分析与 Pelican 一起工作

标签 google-analytics pelican

所以我最近开始用 Pelican 写博客,除了谷歌分析之外,一切都很好。我使用

make s3_upload

命令,它使用 publishconf.py 文件。

要获取我的跟踪 ID,我所做的只是将我的跟踪 ID 从 google 分析页面复制粘贴到 publishconf.py 文件中的 Google Analytics 行,如下所示
# Following items are often useful when publishing

#DISQUS_SITENAME = ""
GOOGLE_ANALYTICS = "UA-########-#"

任何帮助将不胜感激,我一直在绞尽脑汁试图解决这个问题。

最佳答案

解决方案

  • 编辑 publishconf.py

    GOOGLE_ANALYTICS = "UA-########-#"
  • 建立网站

    鹈鹕含量
  • 根据设置修改网站=添加谷歌分析

    鹈鹕-s publishconf.py 。
  • 部署

    cd output && git push origin master

  • 测试 这些步骤有效:
  • 在 output/index.html 的末尾本地添加:
    <script type="text/javascript">
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    
    ga('create', 'UA-125105451-1', 'auto');
    ga('send', 'pageview');
    </script>
    
  • 检查 javascript 代码是否已添加到您的 github 存储库中。检查代码是否在“私有(private)导航”中提供(以禁用浏览器缓存)。右键单击您的网页 > 查看源代码。

  • 上下文 : 部署到 github 页面

    博客的 Git:
    cd output/ 
    git init .
    git remote add origin git@github.com:<username>/<username>.github.io.git
    # Deploy with:
    # git add . && git commit -m "Commit description" && git push origin master
    

    博客引擎的 Git:
    cd output && cd .. # ensure to be in the good repository
    git init .
    git submodule add git@github.com:<username>/<username>.github.io.git output/
    

    关于google-analytics - 让 Google 分析与 Pelican 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42129991/

    相关文章:

    google-analytics - 从Google Analytics(分析)切换到跟踪代码管理器

    android - 使用 google-services.json 时的 autoActivityTracking

    android - 无法同时使用Google Analytics(分析)和Firebase依赖项

    python - 如何在不检查页面的情况下让 pelican 包含 content/some_dir?

    python - 更改 pelican 内容的根文件夹

    python - 查询 Pelican 主题中的特定文章(通过标签/类别)

    javascript - 如何使用 Google Analytics API 只允许选择一个属性

    python - Python-如何进行身份验证从AWS Lambda咨询Google Analytics(分析)?

    python - 发布 Pelican 博客时,CNAME 文件未复制到根输出

    python - 如何选择类别页面作为 Pelican 站点的主页?