I’d like to be able to track tell a friend links so my client can see who’s sending what to who and what the most popular entries are. I know there are a number of threads out there about this, but no one seems to have taken the plunge to make anything.
Here is my thought: make a module that simply installs a new tellafriend table that will hold ‘from’ addresses, ‘to’ addresses, maybe ‘date’, and of course, the entry id. So if someone goes to click tell-a-friend, they fill it out and send it…and this action gets logged to this ‘tellafriend’ table if the module is active. I could then either develop a couple tags for template output or use the query module to figure out the the most emailed entries.
Now, I noticed two hooks that I might be able to use to insert this data into the new table, either before the email is sent or right after the email is sent, both in mod.email.php: email_module_send_email_end, and email_module_tellafriend_override.
Does the tellafriend_override get me the info I need (all the fields to log) to insert into the table? If not, and I have to use the send_email_end hook, how could I distinguish between tell-a-friend emails and any other email being sent? Would this tell-a-friend logging creation be a module or extension? Or both? Thanks for advice on this…or pointing me to something that might already be whipped together 😊 .
Thanks for bringing this up - some good ideas.
A feature request of my own would be to be able to implement a “tell a friend” form on a static page. Currently EE requires an entry id to send data. But, sometimes I want the form to be on a static page – especially when its going to be on a top level navigation page on a site. Right now if I want to do this type of thing on the “About” page for example, I have to create a fake entry and make the url look like it’s part of the directory structure like
/index.php/about/authors
where authors is an entry not holding any data. On a static page I’d like to see some way to over-ride the current tell-a-friend form with a tag that holds the static page url (/index.php/about) and a tag to set message you want to be emailed.
The other part of this is that I would like to echo the desire to track the most emailed pages. Every newspaper in the country does this type of thing and it would be nice to be able to put this functionality on a website.
Right, I was just looking at the NY Times most emailed stories. Turns out my client will be happy with a BCC solution for now, so it won’t be pressing for me to develop - but I know of more than one site I could use this functionality on. It seems like the right hooks are there! Only wish I had about 3 spare days to monkey with this, as I think it would be a nice addition.
You also had a good suggestion in there about being able to email a friend from something other than an “entry” page. I’ll bet the tellafriend_override hook could be used here, somehow - for example, if there is no entry ID, use a url_segment or something.
I had to implement something like this recently and just used Freeform from Solspace to create the form. Then it stored it all in a nice convenient table for me. Would something like this work for you? I can provide more info on how I accomplished it if you’d like.
…It will also work for non-entry pages.
Adrienne
A module would definitely be cool, but if you just need the stats you could track the form submission as a pseudo page view in Google Analytics, exclude /pageview/ (for argument’s sake) from the main profile, and create a new profile that tracked only /pageview/*/ URI’s (eg track the made up /emailed/some-entry-title/). Then you’d get the pretty graphs over time and everything to boot 😊
Obviously you couldn’t pull the data back in to EE as a ‘most emailed..’ thing though, which is the obvious limitation.
Well I’ve figured out how to do send to a friend with freeform thanks to the belated discovery of this bafflingly hard to find page of documentation.
The parameters I needed in my opening freeform tag were as follows:
{exp:freeform:form form_name="sent_to_friend" required="first_name|email|friend_email" notify="[email protected]" template="send_to_friend_notification" send_user_email="yes" user_email_template="send_to_friend" form_id="form-send-to-friend"}
…form fields here…
{/exp:freeform:form}
This gets me a notification mail sent to [email protected] with the freeform template send_to_friend_notification, whilst the recipient of the form receives the contents of the send_to_friend template.
I also created a hidden field <input name=”url” /> and populated it with the url of the page the form is on. This is passed to my freeform template as the custom field “{url}”.
Pretty simple once you get access to the documentation.
@alienne and @Luke Hardiman, please share how you were able to use Freeform to send a tell-a-friend type email. I can’t figure out how to let the user specify the “To:” for the email.
I’m posting a question on their forum to see if I get that answer. If I do, I’ll link to it here.
jorgepinion,
I never did get around to doing my write-up, so I’ll do it now! I am sort of swamped, though, so you’ll have to bear with me as I do this in a giant hurry. Hopefully this will make sense. If it doesn’t, please ask questions and I’ll revise it until it does!
The method I use actually hinges on a parameter of the Freeform form tag: send_user_email .
First we need to create a new field inside the Freeform control panel – i’m going to call it ‘senderemail’ for the sake of the example. I’m also going to assume you know how to do that, and skip instructions. Oh! And while you’re at it, you probably want to create a field called ‘comments’ or ‘message’ or something – Freeform doesn’t have a comments field by default.
Next we create our front-end form. Here’s a stripped-down example:
{exp:freeform:form form_name="tellafriend" required="name|email|senderemail"
send_user_email="yes" user_email_template="some_template" template="brief_version"}
<label>
Your Name: <input type="text" name="name" value="" />
</label>
<label>
Your Email Address: <input type="text" name="senderemail" value="" />
</label>
<label>
Your Friend's Email Address: <input type="text" name="email" value="" />
</label>
<label>
You're sending this page:
<input type="text" readonly="readonly" name="website" value="[POPULATE THIS]" />
</label>
<label>
Email Subject (max 50 characters): <input type="text" name="comments" maxlength="50" value="" />
</label>
{/exp:freeform:form}
Note that the intended recipient’s email address gets put in the ‘email’ field – that means they get a message, because we’ve turned on send_user_email! But we still want to capture the sender’s email, which is why we created that other field above.
Also note that I’m using ‘website’, a default Freeform field, to store the page’s URL for mailing. Populate this however you want – if it’s always going to be a weblog entry, you can use a {path} or {title_permalink} variable; otherwise you might want to use the ‘Fetch Current URI’ plugin. Also note I’ve made the field readonly, to prevent some exploitation.
Lastly we need to go back to the Freeform control panel and create an email template to be used for the notification. (See the user_email_template parameter, above – match the names there so that the right template gets called.) Again, creating Freeform email templates is beyond my current scope; however, it’s pretty easy, and you can copy the Default template and go from there!
So after we’ve done all this, our final outcome is:
We have captured a Freeform entry with the following fields: ‘name’ - Sender’s name ‘senderemail’ - Sender’s email ‘email’ - RECIPIENT’S email ‘website’ - the link ‘comments’ (or whatever you called it) - email subject line (limited to short length to help cut down on spammers using the damn form)
Freeform sends one email to the person whose email is in the ‘email’ field, using the template we named in the user_email_template parameter
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.