Spreadfirefox affiliates: Difference between revisions

No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Spreadfirefox|Go to the Spread Firefox wiki home]]
[[Spreadfirefox|Go to the Spread Firefox wiki home]]


[https://wiki.mozilla.org/Affiliates Go to Spread Firefox Affiliates program home]
[https://wiki.mozilla.org/Affiliates Go to Spread Firefox Affiliates program wiki home]


= Background =
= The Affiliates program =


The Spread Firefox Affiliates program contributes to many Firefox downloads by giving community members HTML buttons to place on their website.  Website visitors click these buttons, which leads to a destination site (e.g. the Firefox download page).
== What is it? ==


The sfx_affiliates module implements the various tools needed by the Affiliates program.
The Affiliates program is a Spread Firefox marketing project.  Community members, or "affiliates", place "buttons" on websites all over the Internet; on blogs, forums, project websites, you name it.


= Version 2 =
Buttons come in many different shapes and forms...


With milestone 3.0, the sfx_affiliates module has been substantially rewritten.
http://sfx-images.mozilla.org/affiliates/thunderbird/reclaimyourinbox_small.png


==== Goals ====
http://sfx-images.mozilla.org/affiliates/Buttons/firefox2/firefox-spread-btn-3.png
The rewrite was done to accomplish a few things...


# Cleanliness of code, comments, and structure this makes it easier to make changes in the future,
http://www.spreadfirefox.com/files/images/affiliates_banners/banner-1.png
# Correctness, i.e. points are counted correctly, aggregate stats are correct, etc
# Testability, this is an awkward system to test because it is spread out over many sites.
# Archiving.  Another big problem with v1 was that we were always deleting records, so if we had a problem longer than a month ago, the only way to get at those records would be to re-parse/tally the logs for that day/week/month


= Features =
Our most popular buttons are the ones that lead to Firefox downloads...


== Buttons ==
http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/FF3_88x31_g.png
== Stats & Points ==


Current affiliates lists
http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/200x32_best-yet.png
* Top 5
* Top 250
** Lists top 250 affiliates, sorted by the number of points each gained over the past 7 days.
* Top Movers


== Content ==
Part of the program involves tracking metrics related to the usage of these buttons.  For example, how many Firefox downloads did Affiliate X create this week by having a button on their blog?


== OG Project page ==
Types of metrics currently tracked:
* Hits - Someone clicked a button
* Downloads - A download button led to someone downloading Firefox.
* Points - Download buttons have a point value associated with them.  This allows users to collect points.
* Last point change - The amount of points a user gained during the tally.  There is no front-end UI for this.  It helps to aggregate other stats/lists.


http://spreadfirefox.com/affiliates
Lists:
* Top 250 - Ordered by the number of downloads over the past 7 days
* Top 5 - Same as Top 250
* Top movers - The top 5 affiliates ordered by (total this week - total last week), where this week is the past 7 days, and last week was between 7-14 days ago.


= Testing =
Points can lead to rewards:
* Featured Foxes
** This program is currently offline.
** Every quarter, 5 affiliates are chosen at random from the Top 250 list.
** Selected affiliates are sent a t-shirt, and their name and point total are displayed on the Affiliates project homepage.
* Upgrade the Web  (upcoming project for 3.5 release)
** A special set of download buttons.
** Users who achieve at least 100 points over two weeks are entered into a raffle.


== Stats ==
== How does it work? ==


Testing affiliates stats tracking requires a special setup because of the architectureCurrently, the stage site is not very useful for testing affiliates button traffic stats.
A button has a few key elements
* Button image, <img src>
** Images are hosted by IT on the static cluster
* Destination, <a href>
** Where does the button link to when someone clicks it?
** This URL has some key elements alsoThis is how the metrics begin.
*** Affiliates user ID and button ID are appended to the destination as query params
*** ex:  mozilla.com/firefox/?from=sfx&uid=555&t=209
*** ?from=sfx - self-explanatory
*** &uid=555 - this is the account ID of the spreadfirefox.com user that owns this button
*** &t=209 - this identifies which button this is


[http://svn.mozilla.org/projects/spreadfirefox.com/logs-parse/affiliates-download-counting/logmaker.php logmaker.php] is a script that can generate fake access logs to be used for testing affiliates traffic.  Hit/download count can be configured.  Optionally, affiliate user/button data can be pulled from a database, which can be used to populate the fake access logs.  Hits/downloads/points per user will be chosen randomly.  The script will output the amount of hits/downloads/points per user ID it generated.


Example procedure:
A script parses the access logs of destination websites, looking for affiliates referrals, using the key elements described above
# Configure logmaker.php
* mozilla.com
## Hit count: 15,000
** We look here for visitors coming '?from=sfx'
## Download count: 12,500
** Each visitor's affiliate ID, button ID, IP address, and timestamp are extracted
## Pull top 250 users from existing DB
* download.mozilla.org
## Pull all active buttons from existing DB
** We look here for downloads that relate to affiliate traffic, using the IP addresses we extracted from mozilla.com logs.
# Run logmaker.php, save output
** If a download occurs from one of these extracted IP addresses, the referrals from this IP address are marked as having a download.
# Run run.pl, save output
** Only one download per IP, per day, can be counted.
# Save current top 250 page (screenshots?)
# Run SFx cron (which will run tally scripts)
# Compare previous to current top 250 (since logmaker.php used only the top 250 users to generate logs, only the top 250 affiliates will be affected, and you can view all changes on this page)


The idea is that logmaker.php tells us how much traffic went in, so we can set expectations for run.pl and the tally script.
Another way to test the tally scripts might be to create a test-tally.sql which could have expected output after the tally code runs.


= Some thoughts by Paul Booker =
All these affiliates referrals are inserted into the SFx database for tallying
When we migrate to D6 it would be great if we could have the latest modifications to the affiliate program ported over to D6 as a satellite module to our "affiliates" module on drupal.org, submitting any generic features back to the affiliates project on drupal.org so that we can maintain the smallest amount of bespoke code in SVN. "Cleanliness of code" and "Correctness" have both been fine with the "affiliates" module since October. "Testability" improvements would be welcomed.
* A script goes over the referrals and tallies hits, downloads, and points for each affiliates.
** If a user doesn't have an existing affiliate record, one is created.
* Next, lists like Top 250 and Top Movers are gathered.
 
== Implementation details ==
* log parse script
** Perl script
** runs on dm-stats01
** [http://svn.mozilla.org/projects/spreadfirefox.com/logs-parse/affiliates-download-counting/run.pl run.pl]
** written by Alex B
** outputs SQL INSERT queries for each affiliate referral record
** a cron job picks up this output file and runs the queries on the SFx DB
* Tally scripts
** PHP code
** runs within Drupal framework
** [http://svn.mozilla.org/projects/spreadfirefox.com/trunk/sites/all/modules/sfx_affiliates/sfx_affiliates.module sfx_affiliates.module]
** most recently rewritten by Alex B
 
== Ideas ==
 
* Have all buttons go through a lightweight jump host, and be redirected to their destination.  This would make the log parsing easier and more efficient.
* Track metrics on sfx-images.mozilla.com, this would tell use how many views buttons get
Confirmed users
884

edits