Skip to main content

pelican-ga-pageview

Google analytics pageview plugin to work with nice blog theme

Page View using Google Analytics

If you track your site's page view using Google Analytics, this plugin can pull the page view information from your Google Analytics profile and add a page_view attribute to each article and page in your Pelican site. See a live example here.

http://jwkennington.com

Requirements and Setup

First, follow the instructions here <https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py>_ to set up Google API service account.

Then in Google Analytics, add the email address you created above as an user so that we can access the Google Anaytics API.

At this point, you should have:

  • Google API service email: <prioject_id>-<unique_id>@developer.gserviceaccount.com
  • Google private key file: client_private.p12. Save this file somewhere secure. If you put this file in a Git repository, don't forget to add it to .gitignore.

Finally, install the Google API Python library:

pip install --upgrade google-api-python-client

Settings

You need to provide the following information in your Pelican configuration file for this plugin to communicate with the Google Analytics API.

  • GOOGLE_SERVICE_ACCOUNT: the service email.
  • GOOGLE_KEY_FILE: path to the private key file, E.g. ./client_private.p12.
  • GA_START_DATE: start date to count page view. E.g., 2005-01-01.
  • GA_END_DATE: end date to count page view. E.g., today.
  • GA_METRIC: counting metrics, default is ga:pageviews. See other options here <https://developers.google.com/analytics/devguides/reporting/core/dimsmets>_. Right now we only support query with ONE metric.
  • POPULAR_POST_START: start date to count popular page views. E.g., A month ago.

With this plugin installed, each article and page object has two extra attributes:

  • pageview: total number of page views between GA_START_DATE and GA_END_DATE.
  • popular_pageview: total number of page view between POPULAR_POST_START and GA_END_DATE.

And there is one global context named total_page_view, which is the total page view of the entire site.

Note

If you encounter this error while building:

NotImplementedError: PKCS12 format is not supported by the PyCrypto library.

Try convert the p12 file to pem file:

openssl pkcs12 -in client_private.p12 -nodes -nocerts > client_private.pem

The password should be notasecret.

Then set GOOGLE_KEY_FILE to be the pem file just generated.

Resources

  • Google Analytics Core Reporting API <https://developers.google.com/analytics/devguides/reporting/core/v3/reference>_
  • Google Analytics Query Explorer <https://ga-dev-tools.appspot.com/query-explorer/>_

Attribution

This plugin is based on the ga_pageview plugin

Metadata

Release files for pelican-ga-pageview 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pelican-ga-pageview 0.1.1
File Size Uploaded Provenance Actions
pelican_ga_pageview-0.1.1.tar.gz 4.3 kB Without provenance Details for pelican_ga_pageview-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pelican-ga-pageview 0.1.1
File Interpreter ABI Platform Actions
pelican_ga_pageview-0.1.1-py3-none-any.whl Python 3 none any Details for pelican_ga_pageview-0.1.1-py3-none-any.whl

Total release size: 9.9 kB

Release files / pelican_ga_pageview-0.1.1.tar.gz

Download URL pelican_ga_pageview-0.1.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e68ac0682e0935e2722af54c51c51346ca710d4827e9d604be339931803931f0
BLAKE2b-256 checksum
How to use checksums
93f7272dc762e659c537d5025551e5dcdf8d61b0ad1d5753883b385bdef4f5f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release files / pelican_ga_pageview-0.1.1-py3-none-any.whl

Download URL pelican_ga_pageview-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8dc0bce43ee2d9b7f6a6185dad89367d46cf42f3a8a9fd65931e8bd2e426641c
BLAKE2b-256 checksum
How to use checksums
6bf2fb30fac68183a3114fda50397b356fa81c6eea8c4e16cfeba81ea44572c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Security for pelican-ga-pageview 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page