<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UTM URL Generator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #fcfdf9;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.utm-generator {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 400px;
}
.utm-generator input[type="text"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
border: 1px solid #ddd;
box-sizing: border-box;
}
.utm-generator button {
width: 100%;
padding: 10px;
margin: 10px 0;
border: none;
border-radius: 4px;
background-color: #ff8000;
color: white;
cursor: pointer;
transition: background-color 0.3s;
}
.utm-generator button:hover {
background-color: #eb9037;
}
#generatedUrl {
background-color: #f3f3f3;
color: #333;
}
</style>
</head>
<body>
<div class="utm-generator">
<input type="text" id="baseUrl" placeholder="Enter Base URL">
<input type="text" id="utmCampaign" placeholder="UTM Campaign">
<input type="text" id="utmSource" placeholder="UTM Source">
<input type="text" id="utmMedium" placeholder="UTM Medium">
<input type="text" id="utmTerm" placeholder="UTM Term (Optional)">
<input type="text" id="utmContent" placeholder="UTM Content (Optional)">
<button id="generateBtn">Generate URL</button>
<input type="text" id="generatedUrl" readonly>
<button id="copyBtn">Copy to Clipboard</button>
</div>
<script>
document.getElementById('generateBtn').addEventListener('click', function() {
const baseUrl = document.getElementById('baseUrl').value;
const utmCampaign = document.getElementById('utmCampaign').value;
const utmSource = document.getElementById('utmSource').value;
const utmMedium = document.getElementById('utmMedium').value;
const utmTerm = document.getElementById('utmTerm').value;
const utmContent = document.getElementById('utmContent').value;
let url = new URL(baseUrl);
url.searchParams.set('utm_campaign', utmCampaign);
url.searchParams.set('utm_source', utmSource);
url.searchParams.set('utm_medium', utmMedium);
if (utmTerm) url.searchParams.set('utm_term', utmTerm);
if (utmContent) url.searchParams.set('utm_content', utmContent);
document.getElementById('generatedUrl').value = url.href;
});
document.getElementById('copyBtn').addEventListener('click', function() {
const generatedUrl = document.getElementById('generatedUrl');
generatedUrl.select();
document.execCommand('copy');
});
</script>
</body>
</html>