The following exercise is intended for new developers unfamiliar with Python. The idea is to provide a reasonably complex project they can implement in their first week while learning the language which requires a variety of python libraries as well as introducing them to the adtech domain and terminology.
The developer should implement this project as if it were production code, taking account for unit tests and error handling. At the end of each task the developer can submit a code review for feedback.
This exercise is to implement a simple pixel server which could be used to track user searches on a single advertiser's website.
- Http server which listens on configurable port.
- Http endpoint which serves a 1x1 transparent gif to incoming GET requests.
- Logs details of request (ip-address, timestamp, user-agent, etc.) to standard out.
- Querystring parameter "st" will contain a list of search terms, these should be parsed and logged.
- Change logging to write to file in avro format.
- Generate user-id first time we see a user.
- Set user-id in a cookie when responding.
- Load list of active advertisers from database.
- Add advertiser-id as new required querystring parameter.
- If advertiser-id is missing or not in active set return error response.
- Add new table to database: data_partners
- Data partner has a name and a url: e.g. "DoubleClick" "http://doubleclickpartner.com/ck=<USER_ID>
- Advertiser can have a one optional data_partner.
- If a data partner is configured for an advertiser then when we receive a pixel request we should redirect to the partner's url, replacing a USER_ID marker with our id for the user.
Add a utility script which can parse a log file of search term pixels and produce a frequency report of top 10 keywords by advertiser-id.
- You can implement the http server with either the standard library or as a WSGI endpoint (with flask or gnunicorn)
- You can use sqlite or mysql for the db.