Archive for September 21, 2011

@dmexco

image

It’s the first day and we are here in Hall 8. Meetings galore but still room to talk, we got live demos and experts on site to chat!

Being personally here for the first time I’ve got to say… WOW!

Very impressive setups and concepts in many of the booths, competition is strong but in the end our tech is simply better ;-)

Part 3 – Rewind to Facebook Connect

In the first blog I showed you how to add the ADTELLIGENCE “tracking pixel” from our Social Analytics+ tool, in the second blog I showed you how I added a WordPress Plugin to access Facebook through the blog. Now in the third I’m going to explain why the second blog post was wrong and what I  did to get a true “Facebook Connect” into the blog and then how I modified the “tracking pixel” to work with the Facebook data.

I’ve been writing these blogs from the perspective of someone who has no idea about our tool as I wanted to show how easy it was to add but also try to catch and address some of the basic questions that might arise. I hit the first of those questions yesterday when I realized that my efforts in the second blog were 1) a learning experience but 2) in vain.

Facebook has made life easy for developers who want to incorporate Facebook and various websites and in the last blog what I settled on was actually a “Social Plugin” and not the Facebook Connect that I really needed. Now it should be said that with Facebook Connect you are in this case actually adding a Facebook User to your WordPress blog. So ensure that “anyone can register” and that a registered user gets the role of “subscriber” initially.

Next you’ll want to deactivate the plugin (if it’s the same one I added) since the new one I found and have tried now seems to work. If not it will kill your WordPress install since they will conflict with each other.

Remember the whole point here is to get more than just the basic data, it’s to get the social data.

Stats after 2 days

Heatmap after 2 days

So here we go off and running, I once again began searching for a proper plugin. Yes at this stage I did considering building the whole FB Connect integration myself but hey there are plugins so why not…

What I finally decided on was the following “Facebook AWD All in One“, it seems to work and I was able to get the Facebook user so I knew Facebook Connect was working.

Configuration was a bit of fun though as there are several other items one has to consider when doing this.

First you needed to do the Facebook APP ID and Secret like before, and the various other preferences by choice. The one new aspect though was the API permissions. Now these are very important. You need to alert your users as to what information from Facebook you are asking them to share with you. Regardless of what you ask though it’s still only based on what they share with everyone, privacy is important after all.

To find out the choices of permissions you can visit the Developer section on API Permissions. For Our “Social Analytics+” tool there are a few things you need to ask for in order to send the data to our tool. We will update you as there are changes in the works for additional data as well.

  • user_about_me – gender, bio, name, the basics
  • user_likes – what they like
  • user_birthday – their age
  • email -Our tool does not but WordPress does need the ability to email users with comment notifications and such.

Settings

Now it’s time to get back to the code, if you remember from the first and second blog we had modified the “header.php” of the WordPress install to get the “tracking pixel” in place. Well to make life a bit easier we are going to move it from the “header.php” and place it in the “footer.php” instead.

So head over to “Appearance” from the admin login on your blog and choose the “editor” option. Find the “body” tag in “header.php” and remove the code we added. Now update that file and choose the “footer.php“.

For me I decided to add the code right after the “DIV” tag for the foot, basically the end of the file.

The basic’s are the following:

<?php
 $companyid = '#######';
 //get the facebook AWD object
 global $AWD_facebook;
 //get the facebook icon if exist and if activated and if there is a facebook account
 if($AWD_facebook->plugin_option['connect_enable'] == 1){
   $fbuid = get_user_meta($user_ID,'fb_uid', true);
   if($fbuid != ''){
    echo '<img src="http://socialanalytic-1085123149.eu-west-1.elb.amazonaws.com/socialanalytic-web-rest/rest/action/'.$companyid.'/'.$fbuid.'/p1/s1" border="0" height="1" width="1">';
   }else{
     echo '<img src="http://socialanalytic-1085123149.eu-west-1.elb.amazonaws.com/socialanalytic-web-rest/rest/action/'.$companyid.'/'.time().'/p1/s1" border="0" height="1" width="1">';
   }
 }
?>

 

However all this does is change the unique User ID, to capture the “social” data we now have to hack a little more into the plugin to get the “access token” to then be able to access more of the user’s social data.

<?php
/*
*  ADTELLIGENCE GmbH Social Analytics+
* (C) 2011 ADTELLIGENCE GmbH
* info@adtelligence.de

<ns0:UserAddRequest xmlns:ns0="http://www.adtelligence.de/socialanalytic/webservice/">
	<id>500064793</id>
	<birthday>1976-02-16</birthday>
	<gender>male</gender>
	<Interests>
		<interest id="20950498489">
			<name>Girl With The Dragon Tattoo</name>
			<category>Book</category>
		</interest>
	</Interests>
</ns0:UserAddRequest>

*/
$adt_user = 'xxxxxxxxxx';
$adt_pwd = 'xxxxxxxxxx';
$companyid = 'xxxxxxxxx';
$url = 'http://socialanalytic-1085123149.eu-west-1.elb.amazonaws.com/socialanalytic-web-rest/rest/user/'.$companyid;
//get the facebook AWD object
global $AWD_facebook;
//get the facebook user ID and user info
if($AWD_facebook->plugin_option['connect_enable'] == 1){
	$fbuid = get_user_meta($user_ID,'fb_uid', true);
	if($fbuid != ""){
		$user = json_decode(file_get_contents('https://graph.facebook.com/'.$fbuid.'?access_token='.$AWD_facebook->fcbk->getAccessToken()),true);
		$xml_data = '<ns0:UserAddRequest xmlns:ns0="http://www.adtelligence.de/socialanalytic/webservice/">'.
						'  <id>'.$fbuid.'</id>'.
						'  <birthday>'.substr($user['birthday'],7,4)."-".substr($user['birthday'],0,2)."-".substr($user['birthday'],4,2).'</birthday>'.
						'  <gender>'.$user['gender'].'</gender>'.
						'  <Interests>';

		$likes = json_decode(file_get_contents('https://graph.facebook.com/'.$fbuid.'/likes?access_token='.$AWD_facebook->fcbk->getAccessToken()),true);

		for ($x = 0; $x < count($likes['data']); $x++) {
			$xml_data .= '   <interest id="'.$likes['data'][$x]['id'].'">'.
							'      <name><![CDATA['.$likes['data'][$x]['name'].']]></name>'.
							'      <category>'.$likes['data'][$x]['category'].'</category>'.
							'    </interest>';
		}
		$xml_data .= '  </Interests>'.
						'</ns0:UserAddRequest>';

		/** use a max of 256KB of RAM before going to disk */
		$fb = fopen('php://temp/maxmemory:256000', 'w');
		if (!$fb) {
		    echo 'could not open temp memory data';
		    exit();
		}
		fwrite($fb, $xml_data);
		fseek($fb, 0);

		$adt_ch  = curl_init($url);
		curl_setopt($adt_ch , CURLOPT_VERBOSE, 1);
		curl_setopt($adt_ch , CURLOPT_HEADER, 0);
		curl_setopt($adt_ch , CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($adt_ch , CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
		curl_setopt($adt_ch , CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
		curl_setopt($adt_ch , CURLOPT_USERPWD, "$adt_user:$adt_pwd");
		curl_setopt($adt_ch , CURLOPT_PUT, 1);
		curl_setopt($adt_ch , CURLOPT_BINARYTRANSFER, 1);
		curl_setopt($adt_ch , CURLOPT_INFILE, $fb);
		curl_setopt($adt_ch , CURLOPT_INFILESIZE, strlen($xml_data));

		if (($result = curl_exec($adt_ch )) === FALSE) {
			echo 'cURL error: '.curl_error($adt_ch )."<br />\n";
		}
		$resultArray = curl_getinfo($adt_ch);

		echo "HTTP_CODE:".$resultArray['http_code'];

		fclose($fb);
		curl_close($adt_ch );
		echo '<img src="http://socialanalytic-1085123149.eu-west-1.elb.amazonaws.com/socialanalytic-web-rest/rest/action/'.$companyid.'/'.$fbuid.'/p1/s1" border="0" height="1" width="1">';
	}else{
		echo '<img src="http://socialanalytic-1085123149.eu-west-1.elb.amazonaws.com/socialanalytic-web-rest/rest/action/'.$companyid.'/'.time().'/p1/s1" border="0" height="1" width="1">';
	}
}
?>

 

You’ll need to of course update/edit the lines (20-22) for “User”, “Pwd” and “CompanyID” these were sent to you via the initial registration email. The “CompanyID” can actually be found in the url after the “/action/” right before we added the timestamp or FB user ID.

Update the file and you should be off and running…

Social Data

 

 

 

Vinod Khosla On The Post-PC Era And Stealth Hamburger Companies

During TechCrunch Disrupt, Khosla Ventures’ Vinod Khoslasat down with Erick Schonfeld. They talked about a range of issues but there were three things Khosla kept coming back to: the “Post-PC” era, Khosla’s “cool dozen”, and a stealth hamburger company.

Yes, a stealth hamburger company.

“We are definitely in a Post-PC era,” Khosla said. “We’re in a new domain where’ it’s impossible to predict what’s going on,” he continued. “I think what mobile is doing is creating this Post-PC era,” he went on to say.

Here’s the video of the interview:


Read the whole article at techcrunch by clicking here.

Part 2 – Facebook Connect and Social Analytics+

In the last blog post, I showed how easy it was to get started using our free version of Social Analytics+ – however the statistics that it tracked was very limited at that point.

Stats to Date

Heatmap

So now it’s time to “turn on” the social though, this means something as simple as adding Facebook Connect to my blog in order to let readers interact via their Facebook account with what I have written on my blog post. To do this I started searching for an existing “Facebook Connect” plugin, of which there are many so take a look around and read them to find one that suits you and what you want to do best. For me this was the “comment” area of my blog.

I decided on the plugin, “Facebook Comments for WordPress

Plugin

Plugin Description

 

Install and Activate

So far so good and pretty easy. Next to so what to do after it’s been activated.

Settings

Settings and Configuration

From here I need to connect to Facebook and create an app, this will give me the ID and Secret I need for the plugin to function properly.

 

Facebook Apps

I won’t go into all the details of creating the Facebook app as they are pretty straightforward.

The rest of the settings are your own preferences, don’t forget to add the “JavaScript” options at the bottom then “update”.

To see it in action just head over to a post on your page and check the comment section.

Not logged in

I opted to show both the Facebook comments as well as the WordPress Comments since my blog has been up for awhile.

Logged In

Now of course I head to my “fanpage” inside of Facebook and there I can let everyone know they can now post with Facebook to the comments of entries.

Fanpage

Of course this is not all we have to do, now we need to modify the changes we made in the first blog to understand that we have a Facebook user ID involved for the “tracking pixel” and thus give us more accurate data and of course the “social” data involved as well. That is for the next blog though.

 

 

Getting started with Social Analytics+

To be specific this is actually the “free” version of Social Analytics+ that we are offering on the site, the paid version have quite a bit more functionality.

To get started head over to the product page and click on “Social Analytics+” from there you can access the “free version“.

Free Version Registration Form

Fill in some quick data and submit.

Success!

Now within a few seconds, maybe a minute, you should have a mail at the address you gave with your login information and the “tracking pixel” information you will need to start the process.

Email confirming registration with your details

So from here we now know how to login to view the activity and of course what the link, “tracking pixel“, is to add to our app, site, etc. In my case I decided to try it on my own blog: fridaymorningreport.tv

Tracking Pixel

My Site and target of the tracking pixel

 

So since I decided to add it to my blog, which is WordPress I’ll now need to login to my admin account on the blog and under “appearance” I will need to edit my blog files directly (a WordPress Plugin would be a nice approach as well and… well you’ll just have to wait and see on that).

WordPress Editor

The area I want to place the pixel I’ve decided will be in the “header.php” file which is part of most every page on the site. I also decided I wanted to place the pixel right after the “body” tag.

Section to add the tracking pixel

So now I will paste the tracking pixel from the mail into the code here.

Tracking Pixel in place

However before saving, I’ll need to set the {user_id}, now if my blog required a login or had several members I could track by the WordPress built in tag for “logged in user” however as I am the only one who logs in, I’ll just use a “timestamp” from PHP to do this.

Modified Tracking Pixel with PHP timestamp

The PHP for that timestamp is the following: ‹?php echo  time(); ?›

Hit “Update File” and you are basically all done with setting up the tracking.

Now as I only added a 1×1 pixel to the site there’s nothing visible on the site itself, however in the backend the data is already live and being collected. In this case since I used the timestamp every click is a new “visit” which is not ideal and why in the next blog post I will be showing you how through the use of “Facebook Connect” we can really start to get the “social” aspect of the tracking and then able to better see how things are moving through the site.

Simple Tracking

 

Switch to our mobile site