Imeplementing tracking and metrics

seanr - July 15, 2009 - 23:13
Project:Short URL
Version:6.x-1.0-beta1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I'm working on a project that requires this module and needs tracking functionality added to it. Much to my delight, the database table already existed but wasn't being used, so the attached patch adds the logging functionality. Step two obviously is creating a page to display it. I'll be working on that over the next few days but wanted to create an issue now in case anyone else wants to contribute to this feature.

AttachmentSize
shorturl.module.patch1.15 KB

#1

irakli - July 26, 2009 - 02:49

Hey Sean,

yeah, I implemented the data-model part, but never got to creating the UI, was kindof hoping somebody like you would help with that :)

If you are interested in contributing your code, that's definitely something this module would benefit from.

thanks

#2

seanr - August 5, 2009 - 17:34

I've been working with it and gotten quite a ways, but there's still plenty more to do. I'll try to get an updated patch up tonight. You can see what I've done here:

http://drupal6.webolutionary.com/shorturl

#3

irakli - August 6, 2009 - 03:09

Very nice.

I am going to start shorturl_ui submodule, soon and this and other such things could roll into that.

Another thing I want to add, and will work on is a settings page. First two settings:
1. ShortURL domain (e.g. Techcrunch.com uses tcrn.ch as its short URL domain and we need to give users easy way to indicate such domain)
2. A textarea where admin can enter comma-delimited list of reserved keywords.

#4

seanr - August 7, 2009 - 15:46

The reserved keyworks issue is already handled by the shorten module. The other one could go as a patch against that too, unless you're looking to give shorturl its own form independent of shorten (and maybe that is worth doing?).

#5

irakli - August 7, 2009 - 15:52

Good point.

I think there is still need for settings if you just install shorturl and don't install shorten. Requiring shorten just for the sake of settings sounds like an overkill. I am also not sure how they tell shorturl to nor produce a blocked short url. Knowing shorturl code, I don't think shorten has a way of doing it. I will have to check. In any case, shorturl should work on its own too, I think.

What if we wrote the part of shorturl settings that shorten also has, into the same variables they do - that way whichever interface you change these settings from (if the two are both installed) - the settings will be synced.

I think it would be the safest integration? And would allow shorten to safely let shorturl know which pathes to not register.

#6

seanr - August 7, 2009 - 20:05

That's possible. Here's a consideration, though. If you do the check in shorturl, how do you report the error back to shorten if someone submits a bad URL? I guess you'd have to do it as a form alter, at that point. I already did that with my tldrestrict module - something like that could be folded into this one (and maybe we'd make it more like the Access Rules page to accommodate both allow and deny).

#7

irakli - August 7, 2009 - 21:49

Not really a problem, unless I am missing something.

Shorturl does not really allow people to suggest URLs (like bit.ly does) it just generates new tokens. If a generated token conflicts with one of the "block URL" ones, it will disregard and re-generate and return the next one. So shorten does not really need to know about it, I think. It will just always get "good" ones and should be happy :)

#8

irakli - August 8, 2009 - 05:50

I was not able to find "reserved keywords" setting in the shorten module settings page (please see the attached image) even though I installed the dev release.

Am I missing something?

AttachmentSize
Picture 14.png 42.54 KB

#9

seanr - August 17, 2009 - 21:26

irakli - not seeing it now myself either. Not sure what happened to it.

#10

CarbonPig - August 18, 2009 - 07:45

Hi seanr and irakli,

I've been following this module development and really like your ideas. What about using http://drupal.org/project/path_blacklist as a related module to reserve paths?

Just a thought from a novice.

-CarbonPig

#11

seanr - August 27, 2009 - 14:07

Updated patch here. Now provides per user tracking and details pages for individual links (still needs work). It also adds a setting to allow duplicate links.

AttachmentSize
shorturl.patch 12.52 KB

#12

irakli - August 27, 2009 - 13:36

Thank you. Will try to review patch as soon as possible.

Many thanks.

#13

seanr - September 18, 2009 - 15:10

I'll have an updated patch coming soon. I've done some more work, but there's still a bit more to go.

#14

irakli - September 18, 2009 - 15:17

Thank you!

#15

southernwood - September 23, 2009 - 09:07

This is looking great, seanr! I've been looking for something that emulates Pretty Links plugin over at Wordpress. Makes sense that we have tracking alongside shortened URLs.

I'll be testing, so looking forward to your next patch.

Update:

On clean install, admin/reports/shorturl -

user warning: Unknown column 'title' in 'field list' query: SELECT lid, orig_url, title, description, keywords, count(aid) as clicks, created, uid FROM shorturl_link sl LEFT JOIN shorturl_access sa ON lid=url_id GROUP BY lid, orig_url ORDER BY clicks DESC LIMIT 0, 50 in /var/www/vhosts/searchenginemarketingspecialists.org/httpdocs/sites/all/modules/shorturl/shorturl.module on line 120.

#16

seanr - September 25, 2009 - 20:51

Looks like the install file needs a field. I'll fix that this weekend. I should actually get most of the remaining functionality done tomorrow, so I'll have another patch either way. BTW, that domain name kinda misses the point of a URL shortener. :-P

#17

EgonO - October 4, 2009 - 18:14

subscribe

#18

gsgchoi - October 8, 2009 - 18:15
Title:Imeplementing tracking and metrics» query failed
Category:feature request» bug report
Priority:normal» critical

Hi, I am trying to use this module but I am getting below error message. It looks like that it fails to create shorturl_link table. Can you please let me know what's the issue here.

# user warning: query: CREATE TABLE shorturl_link ( lid serial CHECK (lid >= 0)(22), orig_url varchar(255) NOT NULL default '', created int NOT NULL default 0, remote_ip varchar(20) default '', PRIMARY KEY (lid) ) in /var/www/webserver.wordstream.com/includes/database.inc on line 517.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "shorturl_link" does not exist in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.

#19

gsgchoi - October 8, 2009 - 18:19

This is the full error message.

# warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "(" at character 58 in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.
# user warning: query: CREATE TABLE shorturl_link ( lid serial CHECK (lid >= 0)(22), orig_url varchar(255) NOT NULL default '', created int NOT NULL default 0, remote_ip varchar(20) default '', PRIMARY KEY (lid) ) in /var/www/webserver.wordstream.com/includes/database.inc on line 517.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "shorturl_link" does not exist in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.

#20

irakli - October 18, 2009 - 20:08
Title:query failed» Imeplementing tracking and metrics

ggschol - please don't rename issues that are about another thing. Just open a new issue. Your query error has nothing to do with implementing metrics, which the original issue was about.

Now regarding your problem (but do open a new issue if you want to continue discussing it):

Looks like you are installing it on PostgreSQL. Module is not tested with Postgres and I would highly advise against using it with postgres. Postgres may have some benefits, but it's definitely way slower than MySQL. MySQL is much more appropriate if you need t use this module and set up a URL Shortener.

That said - if somebody has time to test it with Postgres and provide patch - i would be open to integrating it.

#21

irakli - October 19, 2009 - 14:43

---

#22

seanr - October 19, 2009 - 18:59
Priority:critical» normal

Here's a final patch. I'd like to add some caching to it, but the functionality is 100% working at this point. If we can get this patch reviewed and committed soon, that'd be helpful, as I've had several people asking about it. It's currently live at http://go.usa.gov and http://drupa.ly.

AttachmentSize
shorturl.patch 26.62 KB

#23

seanr - October 26, 2009 - 18:01

OK, final patch with all the improvements we talked about at the meetup.

AttachmentSize
shorturl.patch 27.88 KB

#24

seanr - October 28, 2009 - 22:58
Status:needs work» needs review

#25

R.J. - November 17, 2009 - 03:45

The patch worked but there are a few concernd. When a link has zero clicks, instead of "details for XXX" node, it says "view all 2 links to this page", which only returns one result. See "agile approach" on this page here: http://cmd.to.

The "view own statistics" permission does not work as it should. Users without this permission can still view shorturl/user/uid and shorturl/link/lid, even though they cannot view shorturl/list/lid.

Finally, the All users menu tab is missing and I havent figured out why.

I'll hack away at this later. Thanks for the work, this is great.

#26

R.J. - November 17, 2009 - 03:44

and another weird thing it's doing is creating 200+ links whenever I click on menu link to a node.

edit: I deleted all the created records (973) but can't get it to repeat. I'll submit as a bug next time.

edit: I'll submit this next question as a feature request, too

This may be off-topic, but have you considered implementing short URL as a content type + CCK fields? This would allow integration with views for tracking and metrics....

#27

seanr - November 20, 2009 - 16:15

Regarding links with zero clicks - I cannot reproduce that. I also don't see Agile Approach anywhere on the site you linked to. I couldn't reproduce the menu issue either. I'll look into the permissions issue.

#28

R.J. - November 22, 2009 - 08:39

The patch is no longer live on the site, I reverted back to the original module w/no stats. The site started creating exactly 200 menu links again for every non-shortened link. It's very intermittent; I would delete the excess links but they would re-appear after 24-48 hours. I can't get it to reproduce, I'll keep you posted if I do, any suggestions on testing would be appreciated. Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.