Ajmal Afif's blog

Balancing between consuming knowledge and creating values.

Rails landing page with PostgresQL by Betakit

Tutorial

  1. Set up the server.
1
2
3
4
5
6
$ psql
psql (9.1.4)
Type "help" for help.

username=# CREATE DATABASE betakit_development;
CREATE DATABASE
  1. Migrate the database
1
$ rake db:migrate

That should output something like this:

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
$ rake db:migrate

==  CreateUsers: migrating ====================================================
-- create_table(:users)
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
   -> 0.0043s
==  CreateUsers: migrated (0.0043s) ===========================================

==  AddStateToUser: migrating =================================================
-- add_column(:users, :state, :integer, {:default=>0})
   -> 0.0048s
==  AddStateToUser: migrated (0.0049s) ========================================

==  AddStatsToUsers: migrating ================================================
-- add_column(:users, :stats, :text)
   -> 0.0014s
==  AddStatsToUsers: migrated (0.0015s) =======================================

==  AddRefererToUser: migrating ===============================================
-- add_column(:users, :referer_id, :integer)
   -> 0.0004s
==  AddRefererToUser: migrated (0.0004s) ======================================

==  AddUserAgentToUser: migrating =============================================
-- add_column(:users, :user_agent, :string)
   -> 0.0004s
==  AddUserAgentToUser: migrated (0.0004s) ====================================

==  CreateStatistics: migrating ===============================================
-- create_table(:statistics)
NOTICE:  CREATE TABLE will create implicit sequence "statistics_id_seq" for serial column "statistics.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "statistics_pkey" for table "statistics"
   -> 0.0033s
==  CreateStatistics: migrated (0.0034s) ======================================

==  AddCohorts: migrating =====================================================
-- remove_column(:statistics, :cohort)
   -> 0.0006s
-- add_column(:statistics, :cohort_name, :text)
   -> 0.0016s
-- add_column(:statistics, :cohort_value, :text)
   -> 0.0005s
-- add_column(:statistics, :sample_size, :integer)
   -> 0.0003s
==  AddCohorts: migrated (0.0033s) ============================================

==  RenameCohort: migrating ===================================================
-- rename_column(:statistics, :cohort_value, :cohort_group)
   -> 0.0005s
==  RenameCohort: migrated (0.0006s) ==========================================

Some issues I had

No database found

Fixed by creating database for it in Terminal:

1
2
3
4
5
6
$ psql
psql (9.1.4)
Type "help" for help.

username=# CREATE DATABASE betakit_development;
CREATE DATABASE

Login details not found for localhost

So by default the root URL should link you to the admin page. Let’s have a look at that with rake routes:

1
2
3
4
5
6
7
8
9
10
$ rake routes
                    /                             admin#home
         dashboard  /dashboard(.:format)          admin#reports
                    /report/:stat_name(.:format)  admin#report_stat
api_request_invite  /api/request_invite(.:format) api#request_invite
   api_invite_user  /api/invite_user(.:format)    admin#invite_user
 api_import_emails  /api/import_emails(.:format)  admin#import_emails
 api_export_emails  /api/export_emails(.:format)  admin#export_emails
api_increment_stat  /api/increment_stat(.:format) api#increment_stat
  api_set_app_stat  /api/set_app_stat(.:format)   api#set_app_stat

Now when you visit your root URL of your local copy of betakit (let’s called it http://betakit.dev/ for the sake of example), you will have a prompt that asked for admin and password. How do you log in and get pass that?

Have a look at config/environments/development.rb and you will see this:

1
2
3
# Auth Settings for development
config.auth_username = "admin"
config.auth_password = "password"

So go ahead and fill those in and voila!

Routing root (/) to client/clientTestPage.html

For now

Resource: http://stackoverflow.com/questions/5631145/routing-to-static-html-page-in-public

Inside config/routes.rb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Betakit::Application.routes.draw do

  match '/', :to => redirect('/client/clientTestPage.html')

  match '/admin' => 'admin#home'
  match '/dashboard' => 'admin#reports'
  match '/report/:stat_name' => 'admin#report_stat'

  match '/api/request_invite' => 'api#request_invite'
  match '/api/invite_user' => 'admin#invite_user'
  match '/api/import_emails' => 'admin#import_emails'
  match '/api/export_emails' => 'admin#export_emails'
  match '/api/increment_stat' => 'api#increment_stat'
  match '/api/set_app_stat' => 'api#set_app_stat'

end

Setup for SendGrid

  • Still in progress. Have to wait if it works while account is being provisioned.

live blogging: Google Analytics workshop

Overview

Sources of Data:-

Purpose of GA

Why we track in the first place.

  • Acquisition

    Where are your traffic/people coming from (Linkedin, Facebook etc.). Good example of offline marketing or acquisition is MYEG.

    Dimensions (Rows) always green vs Metrics (Columns) always blue.

    Typically Dimensions has about two levels versus Metrics which could have a lot (more than two).

  • Action

    Once you acquired them, what do you want them to do on your site? Define what those actions are. Answer: create Goal or Event.

  • Retention

    Returning visitors. “Stickiness”.

  • Referral

    Self-explanatory. This could overlap with Acquisition.

  • Revenue

Why Analyze?

  • At the end of the day, it works as “Report Card” to tell about your site performance against your intended goals.
  • Tools:-
    • Google Experiments

Exam-Related Questions

  • Profile changes is NOT retrospective.

  • Setting Up an Account

    • 25 Accounts Maximum
    • 50 Profiles per Account
    • 1250 of total Profiles
    • 10 Million Pageviews limit (monthly)
    • Time Zones (Set Up Once Only)
    • Names of Accounts/Profiles can be changed/deleted
  • (Bonus) Property Settings > WebMaster Tools Settings

  • Creating Filters

    1. Profiles Filters
  • Anatomy Of A Visit

    • 30 minutes is typically length of a visit/session expires
    • When Page load, that’s a Page View
    • GA Query Explorer 2
  • Social Tracking

  • Goals creation

    • Pre-defined goals based on site types [?]

    • Total of 5 goals in one set. There are 4 sets. (20 goals)
    • In Goals, there’s funnel visualization.
  • eCommerce

  • Custom Reporting

    • Study custom reporting pre-defines and popular reporting
    • Only dimensions Filters for Custom Reports. No metrics (blue).
  • Measuring Conversions

    • Events related conversions (Phone Call etc.)
  • Campaigns

    • use campaigns builder here
    • Especially useful for newsletter

Day 2

Goal setting

  • Head Match - to cater thankyou.html with dynamic urls (such as invoices etc.)

Site Search

Virtual Pageviews (track AJAX non-reloaded page)

Custom Variables

  • Page level
  • Session level
  • Visitor levels
1
2
3
4
5
6
_setCustomVar(
index, (required)
name,  (required)
value, (required)
opt_scope (optional)
)

I think this is put inside <head> tag

opt_scope has 3 diff levels:- 1. (visitor-level) 2. (session-level) 3. (page-level)

BigVideo.js: Show fullscreen poster image with BackStretch.js when video ended

Resources

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$(function() {
    var BV = new $.BigVideo();
    BV.init();
if (Modernizr.touch) {
    BV.show('[image-link]');
} else {
    BV.show('[video-link]', {ambient:true});
    _V_("#big-video-vid_html5_api" || "#big-video-vid_flash_api").ready(function(){
       this.addEvent("ended", function(){
          //show poster image
          $('#big-video-vid_html5_api' || '#big-video-vid_flash_api').css('display','none');
          $('.home').backstretch("[image-link]", {target: 'div.intro', positionType: 'absolute'});
       });
    });
}
});

Replace [image-link] and [video-link] with correct URLs.