Introduction
In Canada, new privacy legislation is being introduced to protect consumers from companies using their personal data to charge them different prices. This tutorial will teach you how to build a simple data privacy checker tool that helps users understand how their personal information might be used in pricing decisions. We'll create a web-based tool that simulates how a company might analyze user data to determine pricing strategies.
This tutorial is perfect for beginners who want to understand how personal data can influence pricing and how to build basic privacy monitoring tools.
Prerequisites
Before starting this tutorial, you'll need:
- A web browser (any modern browser will work)
- A text editor (like VS Code, Sublime Text, or even Notepad)
- Basic understanding of HTML, CSS, and JavaScript
- No prior experience with privacy legislation is required
Step-by-Step Instructions
Step 1: Create the HTML Structure
We'll start by creating the basic structure of our privacy checker tool. This will include a form where users can input their personal information and see how it might be used for pricing decisions.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Privacy Pricing Checker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Privacy Pricing Checker</h1>
<p>See how your personal information might influence pricing decisions</p>
<form id="privacyForm">
<div class="form-group">
<label for="age">Age:</label>
<input type="number" id="age" name="age" min="1" max="120" required>
</div>
<div class="form-group">
<label for="location">Location:</label>
<select id="location" name="location" required>
<option value="">Select your location</option>
<option value="urban">Urban Area</option>
<option value="suburban">Suburban Area</option>
<option value="rural">Rural Area</option>
</select>
</div>
<div class="form-group">
<label for="income">Annual Income (CAD):</label>
<input type="number" id="income" name="income" min="0" required>
</div>
<div class="form-group">
<label for="device">Primary Device:</label>
<select id="device" name="device" required>
<option value="">Select your device</option>
<option value="mobile">Mobile Phone</option>
<option value="desktop">Desktop Computer</option>
<option value="tablet">Tablet</option>
</select>
</div>
<button type="submit">Check My Privacy Impact</button>
</form>
<div id="result" class="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
Step 2: Add Basic CSS Styling
Next, we'll create a simple CSS file to make our tool look professional and user-friendly.
/* style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 600px;
margin: 0 auto;
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
}
p {
text-align: center;
color: #666;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input, select {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 30px;
padding: 20px;
border-radius: 5px;
display: none;
}
.result.show {
display: block;
}
.privacy-warning {
background-color: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
}
.privacy-info {
background-color: #d1ecf1;
border: 1px solid #bee5eb;
color: #0c5460;
}
Step 3: Implement JavaScript Logic
Now we'll add the JavaScript functionality that will analyze the user's inputs and simulate how companies might use personal data for pricing decisions.
// script.js
document.getElementById('privacyForm').addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const age = parseInt(document.getElementById('age').value);
const location = document.getElementById('location').value;
const income = parseInt(document.getElementById('income').value);
const device = document.getElementById('device').value;
// Calculate privacy risk score
let privacyScore = 0;
let pricingImpact = '';
// Age factor
if (age < 18) {
privacyScore += 10;
pricingImpact = 'You may be charged a premium for your age group.';
} else if (age > 65) {
privacyScore += 15;
pricingImpact = 'Senior citizens might face higher pricing due to data profiling.';
} else {
privacyScore += 5;
}
// Location factor
if (location === 'urban') {
privacyScore += 20;
if (pricingImpact === '') pricingImpact = 'Urban consumers are often charged more due to higher spending potential.';
} else if (location === 'suburban') {
privacyScore += 10;
} else {
privacyScore += 5;
}
// Income factor
if (income < 30000) {
privacyScore += 25;
if (pricingImpact === '') pricingImpact = 'Lower income consumers may face higher prices based on risk profiling.';
} else if (income > 100000) {
privacyScore += 5;
if (pricingImpact === '') pricingImpact = 'Higher income consumers might get premium pricing.';
} else {
privacyScore += 15;
}
// Device factor
if (device === 'mobile') {
privacyScore += 15;
if (pricingImpact === '') pricingImpact = 'Mobile users may be charged more due to data tracking capabilities.';
} else if (device === 'tablet') {
privacyScore += 10;
} else {
privacyScore += 5;
}
// Generate result
let resultHTML = '';
if (privacyScore < 20) {
resultHTML = ''
+ 'Low Privacy Risk
'
+ 'Your data is likely being used in a minimal way for pricing decisions.
'
+ 'Privacy Score: ' + privacyScore + '
'
+ '';
} else if (privacyScore < 40) {
resultHTML = ''
+ 'Moderate Privacy Risk
'
+ 'Your personal data may influence pricing decisions.
'
+ 'Privacy Score: ' + privacyScore + '
'
+ '' + pricingImpact + '
'
+ '';
} else {
resultHTML = ''
+ 'High Privacy Risk
'
+ 'Your personal data is likely being heavily used for pricing decisions.
'
+ 'Privacy Score: ' + privacyScore + '
'
+ '' + pricingImpact + '
'
+ 'Recommendation: Review your privacy settings and consider how companies use your data.
'
+ '';
}
document.getElementById('result').innerHTML = resultHTML;
});
Step 4: Test Your Privacy Checker
Save all your files (index.html, style.css, and script.js) in the same folder. Open the index.html file in your web browser to test your privacy checker.
Try different combinations of inputs to see how the privacy score changes. For example:
- Enter a young age (18-25) with mobile device usage
- Enter an older age (65+) with high income
- Enter a rural location with low income
This will help you understand how different data points might influence pricing decisions.
Step 5: Understanding the Privacy Implications
As you use this tool, consider how your personal data might be used:
- Location data: Urban consumers might be charged more due to higher spending potential
- Age: Younger or older consumers might face different pricing tiers
- Income: Lower income individuals might be charged more based on risk profiling
- Device usage: Mobile users may be tracked more heavily, affecting pricing
This demonstrates how companies might use your data to personalize pricing, which is exactly what the new Canadian legislation aims to prevent.
Summary
In this tutorial, you've built a simple privacy checker tool that simulates how personal data might be used for pricing decisions. You learned how to:
- Create a basic HTML structure with form elements
- Style the tool using CSS for a professional appearance
- Implement JavaScript logic to analyze user inputs
- Display privacy risk scores based on different data factors
This tool demonstrates the concepts behind the new Canadian privacy legislation that aims to prevent companies from using personal data to charge different prices to different consumers. Understanding how your data might be used helps you make informed decisions about your digital privacy and the services you use.
While this is a simplified simulation, it helps illustrate the real-world implications of data usage in pricing decisions. As privacy laws continue to evolve, tools like this help users understand and monitor their digital rights.



