-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirmation.html
More file actions
88 lines (82 loc) · 3.21 KB
/
Copy pathconfirmation.html
File metadata and controls
88 lines (82 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock Ecomm - Order Confirmation</title>
<script>
window.dataLayer = window.dataLayer || [];
</script>
<script src="assets/js/axeptio-loader.js"></script>
<script src="https://cdn.amplitude.com/script/89bcc735451f7bc5c17d2d992c6b1aa0.experiment.js"></script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PNGFSP9L');</script>
<!-- End Google Tag Manager -->
<link rel="stylesheet" href="assets/css/styles.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body>
<header id="header-placeholder"></header>
<main>
<section class="confirmation-section">
<div id="confirmation-message">
<!-- Confirmation details will be injected here -->
</div>
</section>
</main>
<footer>
<p>© 2025 MockEcomm. All rights reserved.</p>
</footer>
<script src="assets/js/product-data.js"></script>
<script src="assets/js/auth.js"></script>
<script src="assets/js/main.js"></script>
<script src="assets/js/header-loader.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const confirmationContainer = document.getElementById('confirmation-message');
const urlParams = new URLSearchParams(window.location.search);
const transactionId = urlParams.get('id');
const total = parseFloat(urlParams.get('total'));
const cart = JSON.parse(sessionStorage.getItem('cart')) || [];
if (!transactionId || !total) {
confirmationContainer.innerHTML = '<h2>Invalid Confirmation</h2><p>Could not retrieve order details.</p>';
return;
}
// Display confirmation message
confirmationContainer.innerHTML = `
<h2>Thank You For Your Order!</h2>
<p>Your order has been placed successfully.</p>
<p><strong>Transaction ID:</strong> ${transactionId}</p>
<p><strong>Order Total:</strong> $${total.toFixed(2)}</p>
<a href="index.html" class="btn">Continue Shopping</a>
`;
// GA4: page_view for confirmation
window.dataLayer.push(enrichDataLayer({
event: 'page_view',
page_category: 'OrderConfirmation'
}));
// GA4: purchase event
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push(enrichDataLayer({
event: 'purchase',
ecommerce: {
transaction_id: transactionId,
affiliation: 'MockEcomm Online Store',
value: total,
tax: total * 0.07, // Mock tax
shipping: 10.00, // Mock shipping
currency: 'USD',
coupon: '',
items: cart
}
}));
// Clear the cart from storage after purchase event is sent
sessionStorage.removeItem('cart');
});
</script>
</body>
</html>