diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.ex
index 44bbacff0..a62dc0a76 100644
--- a/lib/plausible_web/controllers/auth_controller.ex
+++ b/lib/plausible_web/controllers/auth_controller.ex
@@ -72,9 +72,6 @@ defmodule PlausibleWeb.AuthController do
case Auth.verify_email(user, code) do
:ok ->
- PlausibleWeb.Email.welcome_email(user)
- |> Plausible.Mailer.send_email()
-
redirect(conn, to: "/sites/new")
{:error, :incorrect} ->
render(conn, "activate.html",
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index 3f07de4b6..2676340fe 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -37,6 +37,17 @@ defmodule PlausibleWeb.SiteController do
{:ok, %{site: site}} ->
Plausible.Slack.notify("#{user.name} created #{site.domain} [email=#{user.email}]")
+ is_first_site = !Repo.exists?(
+ from sm in Plausible.Site.Membership,
+ where: sm.user_id == ^user.id
+ and sm.site_id != ^site.id
+ )
+
+ if is_first_site do
+ PlausibleWeb.Email.welcome_email(user)
+ |> Plausible.Mailer.send_email()
+ end
+
conn
|> put_session(site.domain <> "_offer_email_report", true)
|> redirect(to: "/#{URI.encode_www_form(site.domain)}/snippet")
diff --git a/lib/plausible_web/templates/email/welcome_email.html.eex b/lib/plausible_web/templates/email/welcome_email.html.eex
index baca4c8ce..03232fd75 100644
--- a/lib/plausible_web/templates/email/welcome_email.html.eex
+++ b/lib/plausible_web/templates/email/welcome_email.html.eex
@@ -1,14 +1,22 @@
Hey <%= user_salutation(@user) %>,
-I'm building Plausible to provide a simple and ethical approach to tracking website visitors.
-I'm super excited to have you on board!
+We are building Plausible to provide a simple and ethical approach to tracking website visitors.
+We're super excited to have you on board!
-To start collecting stats, you need to <%= link("add a site on Plausible", to: "#{plausible_url()}/sites/new") %>.
+Here are five steps to get the most out of your Plausible experience:
+
+* Serve the script as a <%= link("first party connection from your custom domain", to: "https://docs.plausible.io/custom-domain") %>
+* <%= link("Enable email reports", to: "https://docs.plausible.io/email-reports/") %> and notifications for <%= link("traffic spikes", to: "https://docs.plausible.io/traffic-spikes/") %>
+* <%= link("Integrate with Search Console", to: "https://docs.plausible.io/google-search-console-integration/") %> to get keyword phrases people find your site with
+* Set up some easy goals including <%= link("404 error pages", to: "https://docs.plausible.io/404-error-pages-tracking") %> and <%= link("outbound link clicks", to: "https://docs.plausible.io/outbound-link-click-tracking/") %>
+* <%= link("Opt out from counting your own visits", to: "https://docs.plausible.io/excluding/") %>
+
+Then you're ready to start exploring your fast loading, ethical and actionable <%= link("Plausible dashboard", to: "https://plausible.io/sites") %>.
Have a question, feedback or need some guidance? Do reply back to this email.
Thanks,
-Uku Taht
+Uku and Marko
--
diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs
index 6a1c52b75..8b1e7c1f4 100644
--- a/test/plausible_web/controllers/site_controller_test.exs
+++ b/test/plausible_web/controllers/site_controller_test.exs
@@ -1,6 +1,7 @@
defmodule PlausibleWeb.SiteControllerTest do
use PlausibleWeb.ConnCase
use Plausible.Repo
+ use Bamboo.Test
import Plausible.TestUtils
describe "GET /sites/new" do
@@ -45,6 +46,30 @@ defmodule PlausibleWeb.SiteControllerTest do
assert Repo.exists?(Plausible.Site, domain: "example.com")
end
+ test "sends welcome email if this is the user's first site", %{conn: conn} do
+ post(conn, "/sites", %{
+ "site" => %{
+ "domain" => "example.com",
+ "timezone" => "Europe/London"
+ }
+ })
+
+ assert_email_delivered_with(subject: "Welcome to Plausible")
+ end
+
+ test "does not send welcome email if user already has a previous site", %{conn: conn, user: user} do
+ insert(:site, members: [user])
+
+ post(conn, "/sites", %{
+ "site" => %{
+ "domain" => "example.com",
+ "timezone" => "Europe/London"
+ }
+ })
+
+ assert_no_emails_delivered()
+ end
+
test "cleans up the url", %{conn: conn} do
conn =
post(conn, "/sites", %{