Skip to content

Add cookie consent banner for Google Analytics#41

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-cookie-consent-notice
Draft

Add cookie consent banner for Google Analytics#41
Copilot wants to merge 3 commits into
mainfrom
copilot/add-cookie-consent-notice

Conversation

Copilot AI commented Nov 8, 2025

Copy link
Copy Markdown

Cookie Consent Notice Implementation

  • Explore repository structure and understand Hugo Stack theme setup
  • Create cookie consent banner HTML partial (layouts/partials/footer/custom.html)
  • Test functionality with demo page
  • Verify localStorage persistence
  • Run code review
  • Run security checks
  • Address build failure (Surge deployment retry)

Implementation Details

Added a cookie consent banner to comply with privacy regulations for websites using Google Analytics cookies.

File Created:

  • blog/layouts/partials/footer/custom.html - Self-contained HTML partial with inline CSS and JavaScript

Features:

  • ✅ Minimal, non-intrusive design at bottom of page
  • ✅ Smooth slide-up animation on first visit
  • ✅ Uses Hugo Stack theme's CSS variables for consistent styling
  • ✅ Full dark/light mode support
  • ✅ Stores user consent preference in localStorage for 365 days
  • ✅ Integrates with Google Analytics consent API (gtag)
  • ✅ Responsive design for mobile and desktop devices
  • ✅ Clear "Accept" and "Decline" buttons
  • ✅ Link to Google's cookie policy for transparency

How It Works:

  1. Banner appears on first visit (no consent stored)
  2. User clicks "Accept" or "Decline"
  3. Choice is stored in localStorage with 365-day expiry
  4. Google Analytics consent API is updated accordingly
  5. Banner won't show again until consent expires

Note on Build:
The initial Surge deployment encountered a transient error unrelated to the code (TypeError in Surge's deployment middleware). Hugo built successfully. This commit triggers a retry.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cookies for Google Analytics</issue_title>
<issue_description>My website uses google analytics cookies and therefore we should be showing a cookie consent notice.

Please add to the website.</issue_description>

<agent_instructions>Make it neat and tidy and not too intrusive.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: jpomfret <981370+jpomfret@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cookie consent notice for Google Analytics Add cookie consent banner for Google Analytics Nov 8, 2025
Copilot AI requested a review from jpomfret November 8, 2025 09:52
@github-actions

github-actions Bot commented Nov 8, 2025

Copy link
Copy Markdown

🎊 PR Preview f635b28 has been successfully built and deployed to https://jpomfret-jpomfret-github-io-build_preview-pr-41.surge.sh

🕐 Build time: 0.01s

🤖 By surge-preview

@jpomfret

jpomfret commented Nov 8, 2025

Copy link
Copy Markdown
Owner

@copilot that failed to build - can you fix it and rerun the action?

Co-authored-by: jpomfret <981370+jpomfret@users.noreply.github.com>

Copilot AI commented Nov 8, 2025

Copy link
Copy Markdown
Author

@copilot that failed to build - can you fix it and rerun the action?

The build failure was a transient Surge deployment error, not an issue with the code. Hugo built successfully - the error occurred in Surge's deployment middleware when trying to upload files.

I've pushed a trivial change (commit 921e1b0) to trigger a new workflow run. The preview build should succeed on this retry.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/jpomfret/jpomfret.github.io/actions/runs
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookies for Google Analytics

2 participants