EcoMeter Script

Version 1.0.0 · Website CO₂ analyzer for any PHP website · by OK Multimedia

1. Overview

EcoMeter Script analyzes every page of your website, estimates the CO₂ that one visit produces and gives each page a grade from A+ to F. Then it can show your visitors a seal with the real result of the page they are reading.

It is a self-hosted PHP script: it runs on your own hosting, next to your website, and it does not need WordPress. It works with plain HTML sites, PHP sites, Laravel and other frameworks, and custom CMSs.

Main features:

2. Requirements

RequirementDetails
PHP 7.4 or newerTested from PHP 7.4 to PHP 8.5.
PHP extensionsPDO with the SQLite driver, cURL, DOM and JSON (all usually enabled). zlib is recommended: without it, compressed pages are measured a little less precisely.
A writable folderThe ecometer/data/ folder must be writable by PHP. The installer checks it for you.
Your website must be reachableEcoMeter loads your own pages over HTTP(S), like a visitor, from your server.
Optional: a scheduled taskA cron job keeps the measurements fully automatic. Without one, EcoMeter still measures while the dashboard is open and, little by little, after visits. See section 5.

The installer (step 2) checks all of this and tells you exactly what is missing.

3. What is in the package

ecometer-script-1.0.0/
├── ecometer/            ← the script: upload this folder to your website
│   ├── index.php        installer, login and dashboard
│   ├── badge.js         the seals and eco mode for your visitors
│   ├── badge.php        PHP alternative for the seal line, and the data the seals read
│   ├── cron.php         scheduled measurements
│   ├── assets/          styles, images, fonts and the seal drawing
│   ├── data/            your settings and database (created by the installer)
│   ├── inc/  lang/  views/   the engine, the 8 languages and the screens
├── documentation/       this guide
├── licensing/           licence notes, the GPL and the Poppins font licence
└── README.txt

4. Installation in 3 steps

Step 1 · Upload the folder

Upload the ecometer folder to the root of your website (the folder that contains your home page), with FTP or the file manager of your hosting. You will then have, for example, public_html/ecometer/.

You can rename the folder (for example to keep the dashboard address private). Just use the new name in the addresses below.

Step 2 · Open the installer

Open https://yourwebsite.com/ecometer/ in your browser and follow the four steps:

  1. Welcome and language.
  2. Checks: PHP version, extensions and the data/ folder. Fix anything marked in red, then reload.
  3. Your website and your account: the address of your website and the username and password for the dashboard.
  4. Ready: EcoMeter starts finding and measuring your pages, and gives you the line to show the seal.

When the installation finishes, the installer locks itself: nobody can run it again.

Step 3 · Show the seal

Copy the line from the dashboard (Seals screen) and paste it into your website where you want the seal to appear:

<script src="https://yourwebsite.com/ecometer/badge.js" async></script>

That is all. More options in section 7.

5. Scheduled task (cron)

A scheduled task makes EcoMeter fully automatic: it measures new pages, re-checks every page each week and keeps the CO₂ VERIFIED seal confirmed. Add one of these in the panel of your hosting, every 5 minutes. Your exact lines, with your folder and your private key, are in Dashboard › Settings.

php /home/youruser/public_html/ecometer/cron.php

Or, if your hosting only allows calling an address:

https://yourwebsite.com/ecometer/cron.php?key=YOUR-PRIVATE-KEY

Without the key, cron.php answers "Forbidden". Settings shows when the task last ran.

In Settings you can also choose to measure only at night (from 00:00 to 07:00, server time) and to turn the weekly re-check on or off.

6. The dashboard

Open https://yourwebsite.com/ecometer/ and sign in.

Summary
The average grade and CO₂ of your website, the pages that produce the most CO₂, the measuring queue and any page that could not be measured (with the reason and the next attempt).
Pages
Every page with its grade, CO₂ and size. Search, sort, measure one page again, add a page by hand or remove one. "Find pages" looks for new pages again.
Seals
The CO₂ VERIFIED seal challenge, the seal style and language, colours and size, the lines to paste on your website, and eco mode.
Settings
Your website address, dashboard language, password, night-only and weekly measuring, and the scheduled task.

7. Show the seal on your website

The line

Paste this line where you want the seal (each page shows its own result):

<script src="https://yourwebsite.com/ecometer/badge.js" async data-style="card" data-lang="en"></script>

Several seals, or the seal in a specific place

Put the line once (for example before </body>) and place one or more holders wherever you like:

<div data-ecometer data-style="mini"></div>
<div data-ecometer data-style="card" data-lang="es"></div>

PHP websites

If your pages are PHP, you can use this line instead. It prints the same seal and, when the CO₂ VERIFIED challenge is on, the line our server needs (see section 10):

<?php include $_SERVER['DOCUMENT_ROOT'] . '/ecometer/badge.php'; ?>

First visit to a new page

The first time a page is seen, its seal says "Measuring the CO2 of this page…" until it is measured (a few minutes with the scheduled task). Visitors never wait: they always read a saved figure.

Tracking parameters added by ads, social networks and newsletters (utm_…, fbclid, gclid and similar) are ignored, so those visits show the result of the page itself. To protect your server, visits add at most 30 new pages an hour; the rest are found by "Find pages" and the weekly check.

8. Colours and size

In Seals, choose the background, border and text colours of the seal (or leave "Default"), and the size: small, normal or large. The preview changes as you choose. Press Save: every seal on your website uses the new look, without changing the line.

9. Eco mode for your visitors

Eco mode adds a small tab on the edge of your website. When a visitor switches it on, the page moves and downloads less:

Turn it on in Seals › Eco mode for your visitors and choose the tab position on computers and on phones. It appears on every page that has the EcoMeter line. The visitor's choice is remembered in their browser (local storage); no cookies are used. Visitors who ask their device for reduced motion get eco mode without the animation of the tab.

10. CO₂ VERIFIED seal

Keep your website at A or A+ for 30 days in a row and earn the CO₂ VERIFIED seal. Our server checks your website every day: the home page and two random pages. A day at B or below starts the count again.

  1. In Seals, copy the line shown in the CO₂ VERIFIED card and paste it in the <head> of your home page. It looks like this (yours has its own code):
    <meta name="ecometer-seal" content="…">
    If your website uses the PHP line from section 7 on the home page, it is already there.
  2. Press Start. The count begins; the card shows the days and the last check.
  3. After 30 days, press Get the seal.
  4. Place the seal wherever you like, together with the EcoMeter line:
    <div data-ecometer-seal data-size="160"></div>
    data-size is the width in pixels (60 to 600). The seal links to its public verification page on okmultimedia.com.

The seal is shown only while the service confirms it (it is checked again at least once a day). If our server cannot find the line on your home page, the daily check stops: press Start again. You can leave the challenge at any time ("Leave the challenge").

The line on your home page contains only a fingerprint (SHA-256) of a private code that never leaves your server. Pressing Start sends your home page address and that private code to the verification service; nothing else. Service terms and privacy: okmultimedia.com/en/ecometer/terms.

11. How the CO₂ is estimated

EcoMeter loads each page as a first-time desktop visitor would (1440 px wide) and adds up everything that visit downloads: HTML, styles, scripts, images (choosing the same file as a browser from srcset and <picture>), fonts and video. It then turns that data into energy and CO₂ with the Sustainable Web Design model, version 4, published by the Green Web Foundation, and gives a grade from A+ to F.

It is an estimate. Real emissions depend on things no website can see: the visitor's device and network, the data centre and the energy mix. EcoMeter gives a consistent, comparable figure to help you improve your pages.

Limits, so a measurement never overloads your server:

12. Languages

The installer, the dashboard, the seals, the details window and eco mode are available in English, Spanish, French, Portuguese, German, Russian, Arabic (right to left) and Chinese. Choose the dashboard language in Settings and the seal language in Seals (or per line with data-lang).

13. Security

Nginx servers

Nginx does not read .htaccess files. Add this to your site configuration (adjust the folder name if you renamed it):

location ~ ^/ecometer/(data|inc|lang|views)/ { deny all; }

Forgot your password?

Create an empty file called reset.txt inside ecometer/data/ (with FTP or your hosting's file manager) and open the dashboard: you can choose a new password. The file is deleted afterwards.

14. Updating

  1. Download the new version.
  2. Upload the new ecometer folder over the old one, keeping your ecometer/data/ folder (it holds your settings and measurements).
  3. Open the dashboard. Nothing else is needed.

15. Uninstalling

  1. Remove the EcoMeter lines from your website (the seal line, the holders and, if you used it, the CO₂ VERIFIED line).
  2. If you joined the CO₂ VERIFIED challenge, press "Leave the challenge" first.
  3. Delete the ecometer folder and the scheduled task.

Deleting the folder deletes all EcoMeter data too (settings and measurements live only in ecometer/data/). Nothing is left in any other place of your website or database.

16. External services and privacy

17. Troubleshooting & FAQ

The installer shows something in red.
Follow the message: usually the data/ folder is not writable (set it to 755 or 775 in your file manager) or a PHP extension is disabled (enable PDO SQLite or cURL in your hosting's PHP settings). Reload the page after the change.
The seal says "Measuring the CO2 of this page…" for a long time.
The page has not been measured yet. Set up the scheduled task (section 5) or open the dashboard and press "Measure all". If the page appears in Summary as "could not be measured", see the reason there and press "Retry".
The seal does not appear at all.
Check that the line points to your real folder (open https://yourwebsite.com/ecometer/badge.js: it must show code). If your website uses a strict Content Security Policy, allow your own domain for scripts. If you use a cache or CDN, clear it.
A page could not be measured.
Summary shows the reason (timeout, too many failed files, page not found…). EcoMeter tries again automatically after 10 minutes, 1 hour and 6 hours; you can also press "Retry". Pages that need a login cannot be measured.
"Start" in CO₂ VERIFIED gives an error.
Our server could not find the line on your home page. Make sure it is inside <head> of the home page and, if you use a cache plugin or CDN, clear it. Then press Start again.
The CO₂ VERIFIED seal disappeared.
It is shown only while the service confirms it. Open the dashboard (Seals): press "Update". If the daily check stopped, the line is missing from the home page: put it back and press "Start again".
I moved my website to another address.
Change the address in Settings and press "Find pages". For CO₂ VERIFIED, press "Leave the challenge" and Start again on the new address.
Does it slow my website down?
No. Visitors only read a small saved result. Measurements run in the background, one page at a time, with time and file limits.
Can I use it on several websites?
Each installation measures one website. Your purchase includes support and updates for the number of websites of the plan you bought (see section 20 for the licences).
My server is Nginx.
Add the rule from section 13 to keep the internal folders closed.

18. Support

We are happy to help with installation and setup. Please contact us through the Support section of the product page on the marketplace where you bought EcoMeter Script. Tell us your PHP version, your hosting and what you see (a screenshot helps). We usually answer within 24 hours on working days.

19. Changelog

1.0.0

First release.

20. Credits and licences