adkit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/Rakefile +8 -0
- data/Vagrantfile +32 -0
- data/adkit.gemspec +38 -0
- data/lib/adkit.rb +67 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc696a7e1180684bd2ceb9a5de358491c7eb4d9a19e8b1fe8e4c3c56d2a05e6d
|
4
|
+
data.tar.gz: adc654e90b4c0cac33502c4f1549623557a7dd064490329f3bd2716d9a2b0269
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a949fb700fa2257c80b7340a5c0b45bd3312f3c55ccc594379299b0af0e6084e08c8d57a6de2f068793f0b73ab48d0c1e8b9e45cfb01305143957ddb24ddcd97
|
7
|
+
data.tar.gz: 4ffe3538e86df6a1fa84626877fac15f2bf6c170c17646b10106ab156ecd8ab97e5cffe05d5dd2fe98fa3faffccddd0f50b4865662f152f10253ffe41e24037f
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Sean Walker
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# adkit
|
2
|
+
|
3
|
+
Easy marketing calculations
|
4
|
+
|
5
|
+
## Conversion Rate
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
total = 1_000
|
9
|
+
conversions = 15
|
10
|
+
|
11
|
+
Adkit.conversion_rate(total, conversions) # => 1.5
|
12
|
+
|
13
|
+
# or if you like acronyms
|
14
|
+
Adkit.cvr(total, conversions) # => 1.5
|
15
|
+
```
|
16
|
+
|
17
|
+
## Lift
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
total = 1_000
|
21
|
+
conversions = 30
|
22
|
+
|
23
|
+
control = 100
|
24
|
+
control_conversions = 1
|
25
|
+
|
26
|
+
Adkit.lift(total, conversions, control, control_conversions) # => 200.0
|
27
|
+
```
|
28
|
+
|
29
|
+
## Cost Per Action
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
cost = 9_876
|
33
|
+
conversions = 1_000
|
34
|
+
|
35
|
+
Adkit.cost_per_action(cost, conversions) # => 10.0
|
36
|
+
|
37
|
+
# or
|
38
|
+
|
39
|
+
Adkit.cpa(cost, conversions) # => 10.0
|
40
|
+
```
|
41
|
+
|
42
|
+
## Incremental Cost Per Action
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
total = 5_000
|
46
|
+
cost = 100
|
47
|
+
conversions = 1_000
|
48
|
+
control = 100
|
49
|
+
control_conversions = 5
|
50
|
+
|
51
|
+
Adkit.incremental_cpa(total, cost, conversions, control, control_conversions) # => 0.1333333
|
52
|
+
|
53
|
+
# or
|
54
|
+
|
55
|
+
Adkit.cpia(total, cost, conversions, control, control_conversions) # => 0.1333333
|
56
|
+
|
57
|
+
# or
|
58
|
+
|
59
|
+
Adkit.icpa(total, cost, conversions, control, control_conversions) # => 0.1333333
|
60
|
+
```
|
61
|
+
|
62
|
+
## Average Order Value
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
revenue = 123_456
|
66
|
+
conversions = 345
|
67
|
+
|
68
|
+
Adkit.average_order_value(revenue, conversions) # => 357.8434782608696
|
69
|
+
|
70
|
+
# or
|
71
|
+
|
72
|
+
Adkit.aov(revenue, conversions) # => 357.8434782608696
|
73
|
+
```
|
74
|
+
|
75
|
+
## Return on Ad Spend
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
revenue = 12_345
|
79
|
+
cost = 987
|
80
|
+
|
81
|
+
Adkit.return_on_ad_spend(revenue, cost) # => 1250.759878419453
|
82
|
+
|
83
|
+
# or
|
84
|
+
Adkit.roas(revenue, cost)
|
85
|
+
```
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# Provisioning script
|
5
|
+
$script = <<SCRIPT
|
6
|
+
echo "*** Updating packages"
|
7
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y aptitude
|
8
|
+
sudo DEBIAN_FRONTEND=noninteractive aptitude update
|
9
|
+
sudo DEBIAN_FRONTEND=noninteractive aptitude -y safe-upgrade
|
10
|
+
echo "*** Installing new packages"
|
11
|
+
sudo DEBIAN_FRONTEND=noninteractive aptitude install -y curl git-core vim
|
12
|
+
if rvm -v 2>/dev/null; then
|
13
|
+
echo "*** rvm already installed, skipping"
|
14
|
+
else
|
15
|
+
echo "*** Installing rvm"
|
16
|
+
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
17
|
+
curl -sSL https://get.rvm.io | bash -s stable --ruby
|
18
|
+
echo "gem: --no-document" > ~/.gemrc
|
19
|
+
echo "*** Finished installing rvm"
|
20
|
+
fi
|
21
|
+
echo "*********************"
|
22
|
+
echo "PROVISIONING FINISHED"
|
23
|
+
echo "*********************"
|
24
|
+
SCRIPT
|
25
|
+
|
26
|
+
|
27
|
+
Vagrant.configure('2') do |config|
|
28
|
+
config.vm.box = 'ubuntu/xenial64'
|
29
|
+
config.vm.hostname = 'adkit-dev'
|
30
|
+
|
31
|
+
config.vm.provision 'shell', inline: $script, privileged: false
|
32
|
+
end
|
data/adkit.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'adkit'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'adkit'
|
7
|
+
spec.version = Adkit::VERSION
|
8
|
+
spec.authors = ["Sean Walker"]
|
9
|
+
spec.email = [""]
|
10
|
+
|
11
|
+
spec.summary = %q{Easy marketing calculations}
|
12
|
+
spec.description = %q{A bundle of common marketing calculations}
|
13
|
+
spec.homepage = "https://github.com/swlkr/adkit"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/swlkr/adkit"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/swlkr/adkit/CHANGELOG.md"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.required_ruby_version = '~> 2.4'
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
37
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
38
|
+
end
|
data/lib/adkit.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Adkit
|
2
|
+
VERSION = '0.1.0'.freeze
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def cvr(total, conversions)
|
6
|
+
if total.zero?
|
7
|
+
0.0
|
8
|
+
else
|
9
|
+
100.0 * conversions / total.to_f
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
alias conversion_rate cvr
|
14
|
+
|
15
|
+
def lift(total, conversions, control, control_conversions)
|
16
|
+
real_cvr = cvr(total, conversions)
|
17
|
+
control_cvr = cvr(control, control_conversions)
|
18
|
+
|
19
|
+
if control_cvr.zero?
|
20
|
+
0.0
|
21
|
+
else
|
22
|
+
100.0 * (real_cvr - control_cvr) / control_cvr
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def cpa(cost, conversions)
|
27
|
+
if conversions.zero?
|
28
|
+
0.0
|
29
|
+
else
|
30
|
+
cost / conversions.to_f
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
alias cost_per_action cpa
|
35
|
+
|
36
|
+
def incremental_cpa(total, cost, conversions, control, control_conversions)
|
37
|
+
if control.zero?
|
38
|
+
0.0
|
39
|
+
else
|
40
|
+
cpa(cost.to_f, conversions.to_f - (control_conversions.to_f * (total.to_f / control)))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
alias cpia incremental_cpa
|
45
|
+
alias icpa incremental_cpa
|
46
|
+
|
47
|
+
def aov(revenue, conversions)
|
48
|
+
if conversions.zero?
|
49
|
+
0.0
|
50
|
+
else
|
51
|
+
revenue / conversions.to_f
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
alias average_order_value aov
|
56
|
+
|
57
|
+
def roas(revenue, cost)
|
58
|
+
if cost.zero?
|
59
|
+
0.0
|
60
|
+
else
|
61
|
+
100.0 * revenue / cost.to_f
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
alias return_on_ad_spend roas
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Walker
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
description: A bundle of common marketing calculations
|
42
|
+
email:
|
43
|
+
- ''
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- Vagrantfile
|
55
|
+
- adkit.gemspec
|
56
|
+
- lib/adkit.rb
|
57
|
+
homepage: https://github.com/swlkr/adkit
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
homepage_uri: https://github.com/swlkr/adkit
|
62
|
+
source_code_uri: https://github.com/swlkr/adkit
|
63
|
+
changelog_uri: https://github.com/swlkr/adkit/CHANGELOG.md
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2.4'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.1.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Easy marketing calculations
|
83
|
+
test_files: []
|