Skip to content

Commit 787f42d

Browse files
committed
Track newsletter signups
1 parent 7c30f17 commit 787f42d

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

_includes/footer.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<script type="text/javascript" src="{{ "/assets/js/index.js" | relative_url }}"></script>
12
<footer class="w-full text-center text-gray-500 p-8 bottom-0" style="background: #191e38;">
23
<div class="container flex items-center justify-between flex-col md:flex-row py-4">
34
<div class="text-center md:text-left">

_layouts/post.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h1 class="text-3xl mt-2 tracking-tight leading-10 font-extrabold text-gray-900
4343
</div>
4444

4545
<div class="container max-w-screen-sm mt-12">
46-
<form class="mt-8 sm:flex justify-center" action="https://plausible.us20.list-manage.com/subscribe/post?u=aa3638e2a24986bbda7c17506&id=a307649d1b" method="post">
46+
<form class="mt-8 sm:flex justify-center" id="newsletter-signup" action="https://plausible.us20.list-manage.com/subscribe/post?u=aa3638e2a24986bbda7c17506&id=a307649d1b" method="post">
4747
<input type="email" name="EMAIL" required class="appearance-none w-full px-5 py-3 border border-gray-300 text-base leading-6 rounded-md text-gray-900 bg-white placeholder-gray-500 focus:outline-none focus:shadow-outline focus:border-blue-300 transition duration-150 ease-in-out sm:max-w-xs" placeholder="Enter your email" />
4848
<div class="mt-3 rounded-md shadow sm:mt-0 sm:ml-3 sm:flex-shrink-0">
4949
<button class="w-full flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out">

assets/js/index.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var newsletterForm = document.getElementById('newsletter-signup')
2+
3+
if (newsletterForm) {
4+
newsletterForm.addEventListener('submit', function(e) {
5+
e.preventDefault();
6+
setTimeout(submitForm, 1000);
7+
var formSubmitted = false;
8+
9+
function submitForm() {
10+
if (!formSubmitted) {
11+
formSubmitted = true;
12+
newsletterForm.submit();
13+
}
14+
}
15+
16+
plausible('Newsletter signup', {callback: submitForm});
17+
})
18+
}

blog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1 class="text-4xl font-black">The Plausible Blog</h1>
1313
</div>
1414

1515
<div class="container max-w-screen-sm mt-12">
16-
<form class="mt-8 sm:flex justify-center" action="https://plausible.us20.list-manage.com/subscribe/post?u=aa3638e2a24986bbda7c17506&id=a307649d1b" method="post">
16+
<form class="mt-8 sm:flex justify-center" action="https://plausible.us20.list-manage.com/subscribe/post?u=aa3638e2a24986bbda7c17506&id=a307649d1b" method="post" id="newsletter-signup">
1717
<input type="email" name="EMAIL" required class="appearance-none w-full px-5 py-3 border border-gray-300 text-base leading-6 rounded-md text-gray-900 bg-white placeholder-gray-500 focus:outline-none focus:shadow-outline focus:border-blue-300 transition duration-150 ease-in-out sm:max-w-xs" placeholder="Enter your email" />
1818
<div class="mt-3 rounded-md shadow sm:mt-0 sm:ml-3 sm:flex-shrink-0">
1919
<button class="w-full flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:shadow-outline transition duration-150 ease-in-out">

0 commit comments

Comments
 (0)