Skip to content

Commit

Permalink
Monitor bootcamp (#7197)
Browse files Browse the repository at this point in the history
* Save where people come from

* Save where people come from

* Fix schema version
  • Loading branch information
iHiD authored Dec 16, 2024
1 parent 0ed76bd commit 017c4e8
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 9 deletions.
10 changes: 9 additions & 1 deletion app/controllers/bootcamp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class BootcampController < ApplicationController
layout 'bootcamp'

skip_before_action :authenticate_user!
before_action :save_utm!
before_action :setup_data!
before_action :setup_pricing!

Expand Down Expand Up @@ -142,7 +143,7 @@ def lookup_country_code_from_ip
def create_bootcamp_data!
return if @bootcamp_data

@bootcamp_data = User::BootcampData.create!(ppp_country: @country_code_2)
@bootcamp_data = User::BootcampData.create!(ppp_country: @country_code_2, utm: session[:utm])
session[:bootcamp_data_id] = @bootcamp_data.id
end

Expand Down Expand Up @@ -174,4 +175,11 @@ def setup_pricing!
@full_complete_price = User::BootcampData::COMPLETE_PRICE
@full_part_1_price = User::BootcampData::PART_1_PRICE
end

def save_utm!
session[:utm] ||= {}
session[:utm][:source] = params[:utm_source] if params[:utm_source].present?
session[:utm][:medium] = params[:utm_medium] if params[:utm_medium].present?
session[:utm][:campaign] = params[:utm_campaign] if params[:utm_campaign].present?
end
end
12 changes: 12 additions & 0 deletions app/javascript/bootcamp/gtag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document.addEventListener(
'turbo:load',
function (event) {
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'AW-303924066')
},
false
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function BootcampAdvertismentView() {
</header>
<div className="flex gap-8">
<a
href="https://bootcamp.exercism.org"
href="https://bootcamp.exercism.org?utm_source=exercism&utm_medium=seniority"
className="btn-primary btn-l cursor-pointer"
>
Go to the Bootcamp ✨
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function JuniorView() {
</header>
<div className="flex gap-8">
<a
href="https://bootcamp.exercism.org"
href="https://bootcamp.exercism.org?utm_source=exercism&utm_medium=welcome"
className="btn-primary btn-l cursor-pointer"
>
Go to the Bootcamp ✨
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ export function InfoMessage({
<p className="text-p-base mb-12">
To thank you for being an Insider and to help increase the amount of
people signing up to Exercism's{' '}
<a href="https://bootcamp.exercism.org">Learn to Code Bootcamp</a>, we
are giving all Insiders an{' '}
<a href="https://bootcamp.exercism.org?utm_source=exercism&utm_medium=affiliate_settings">
Learn to Code Bootcamp
</a>
, we are giving all Insiders an{' '}
<strong className="font-semibold">Discount Affiliate code</strong>.
</p>
<p className="text-p-base mb-12">
Expand Down Expand Up @@ -121,8 +123,10 @@ export function InfoMessage({
return (
<p className="text-p-base mb-16">
Exercism Insiders can access 20% off Exercism's{' '}
<a href="https://bootcamp.exercism.org">Learn to Code Bootcamp</a>,
and receive 20% of all sales when someone uses their voucher code.
<a href="https://bootcamp.exercism.org?utm_source=exercism&utm_medium=affiliate_settings">
Learn to Code Bootcamp
</a>
, and receive 20% of all sales when someone uses their voucher code.
</p>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export default function BootcampFreeCouponForm({
<h2 className="!mb-8">Free Seat on the Bootcamp</h2>
<p className="text-p-base mb-12">
As a lifetime insider you're eligible for a free seat on Exercism's{' '}
<a href="https://bootcamp.exercism.org">Learn to Code Bootcamp</a>.
<a href="https://bootcamp.exercism.org?utm_source=exercism&utm_medium=free_settings">
Learn to Code Bootcamp
</a>
.
</p>
<p className="text-p-base mb-16">
To claim your free seat, we're providing you with a discount code that
Expand Down
1 change: 1 addition & 0 deletions app/javascript/packs/bootcamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import '../bootcamp/confetti-at-footer-animation'
import '../bootcamp/arrow-animation'
import '../bootcamp/checkout'
import '../bootcamp/return'
import '../bootcamp/gtag'
2 changes: 2 additions & 0 deletions app/models/user/bootcamp_data.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class User::BootcampData < ApplicationRecord
serialize :utm, JSON

belongs_to :user, optional: true

after_save do
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/bootcamp.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
= javascript_include_tag('bootcamp', type: :module, crossorigin: :anonymous, 'data-turbo-track': 'reload', 'data-turbo-eval': false, defer: true)

%script{ defer: true, "data-domain": "bootcamp.exercism.org", src: "https://plausible.io/js/script.outbound-links.revenue.tagged-events.js" }
%script{ async: true, "data-turbo-track": "reload", src: "https://www.googletagmanager.com/gtag/js?id=AW-303924066" }
%title= content_for(:title) || "Bootcamp"
%meta{ content: "width=device-width,initial-scale=1", name: "viewport" }/
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20241216055937_add_utm_to_bootcamp_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddUtmToBootcampData < ActiveRecord::Migration[7.0]
def change
return if Rails.env.production?

add_column :user_bootcamp_data, :utm, :text, null: true
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_11_08_083100) do
ActiveRecord::Schema[7.0].define(version: 2024_12_16_055937) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
Expand Down Expand Up @@ -1314,6 +1314,8 @@
t.string "name"
t.string "email"
t.string "ppp_country"
t.string "checkout_session_id"
t.text "utm"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_user_bootcamp_data_on_user_id", unique: true
Expand Down

0 comments on commit 017c4e8

Please sign in to comment.