This repository contains a script, check_ga_tracking.js
, that automates testing of Google Analytics tracking on a website using browser automation. This script simulates user interactions and validates that the appropriate tracking events are being sent to Google Analytics.
- Node.js (version 12+ recommended)
- A website with Google Analytics and Google Tag Manager properly installed and configured
- A testing plan that defines the objectives, test scenarios, and expected outcomes for each test case
- Clone the repository
- Navigate to the project directory
- Install the required dependencies:
npm install
- Update the
config.json
file with the appropriate settings for your website, including the URL, user interactions to be tested, and the expected Google Analytics events.
You can find a template config in the repository.
To run the check_ga_tracking.js
script, use the following command:
node check_ga_tracking.js
This will execute the script, simulating the defined user interactions on your website, and validating that the correct tracking events are being sent to Google Analytics. If there are any discrepancies or issues, the script will output them in the console.
The results are saved as a JSON and CSV files.
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature-branch
) - Commit your changes (
git commit -am 'Add a new feature'
) - Push to the branch (
git push origin feature-branch
) - Create a new Pull Request
This project is licensed under the MIT License. See the LICENSE file for more details.