<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jensbits.com &#187; webdesign</title>
	<atom:link href="http://www.jensbits.com/tag/webdesign/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jensbits.com</link>
	<description></description>
	<lastBuildDate>Wed, 21 Jul 2010 03:44:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Modal Confirmation Dialog on Form Submit: Javascript, jQuery UI, and Thickbox Varieties</title>
		<link>http://www.jensbits.com/2009/08/10/modal-confirmation-dialog-on-form-submit-javascript-jquery-ui-and-thickbox-varieties/</link>
		<comments>http://www.jensbits.com/2009/08/10/modal-confirmation-dialog-on-form-submit-javascript-jquery-ui-and-thickbox-varieties/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 13:15:15 +0000</pubDate>
		<dc:creator>jen</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.jensbits.com/?p=336</guid>
		<description><![CDATA[jQuery files updated June 23, 2010 If you liked this post, you might also like the jQuery.ajax and jQuery.post Form Submit Examples with PHP post. I wanted to make a nice modal dialog box that would confirm submission of a form. And, specifically, it had to ask if their e-mail address was correct that they [...]


Related posts:<ol><li><a href='http://www.jensbits.com/2009/10/23/jquery-ajax-and-jquery-post-form-submit-examples-with-coldfusion/' rel='bookmark' title='Permanent Link: jQuery.ajax and jQuery.post Form Submit Examples with ColdFusion'>jQuery.ajax and jQuery.post Form Submit Examples with ColdFusion</a></li>
<li><a href='http://www.jensbits.com/2009/10/04/jquery-ajax-and-jquery-post-form-submit-examples-with-php/' rel='bookmark' title='Permanent Link: jQuery.ajax and jQuery.post Form Submit Examples with PHP'>jQuery.ajax and jQuery.post Form Submit Examples with PHP</a></li>
<li><a href='http://www.jensbits.com/2010/06/16/jquery-modal-dialog-close-on-overlay-click/' rel='bookmark' title='Permanent Link: jQuery Modal Dialog Close on Overlay Click'>jQuery Modal Dialog Close on Overlay Click</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>jQuery files updated June 23, 2010</strong></p>
<blockquote><p>If you liked this post, you might also like the <a href="/2009/10/04/jquery-ajax-and-jquery-post-form-submit-examples-with-php/">jQuery.ajax and jQuery.post Form Submit Examples with PHP</a> post.</p></blockquote>
<p>I wanted to make a nice modal dialog box that would confirm submission of a form. And, specifically, it had to ask if their e-mail address was correct that they listed on the form. Typos, particularly transposed letters, cause a number of undeliverable e-mails. Making matters worse, sometimes by the time they get to the &#8216;Submit&#8217; button, the all important e-mail field is no longer in view. Yes, despite the web developer&#8217;s best efforts, people still manage to type in their own e-mail incorrectly. I&#8217;ve done it. We&#8217;re all human.</p>
<p>I already knew about the javascript 1.0 method of &#8216;return confirm&#8217; but I wanted more control over the look and feel. As an added requirement, I wanted to use Thickbox since I already had that loaded into the app. I don&#8217;t like throwing in a bunch of js files for every little nuance. If I can use what I already have, it makes the app much leaner.</p>
<p>So, I Googled it. I only found partial solutions. I wanted to go all the way and have the modal box pop up whether the user hit &#8216;Submit&#8217; or whether they hit enter on the keyboard in as many browsers as possible (hint: IE). Maybe I didn&#8217;t look hard enough, but I ended up creating the solution on my own.</p>
<p>Here are three examples (including <a href="http://jensbits.com/demos/forms/index.php">a complete demo</a>) of a form submission confirmation dialog. One each for just javascript, the jQuery UI dialog box, and Thickbox.</p>
<h2>Javascript 1.0</h2>
<p>For pure javascript it&#8217;s painfully straightforward:</p>
<pre class="brush: xml;">
&lt;form id=&quot;testconfirmJS&quot; name=&quot;testconfirmJS&quot; method=&quot;post&quot; onsubmit=&quot;return confirm('You entered your e-mail address as:\n\n' + document.getElementById('emailJS').value + '\n\nSelect OK if correct or Cancel to edit.')&quot;&gt;&gt;
&lt;fieldset&gt;
&lt;legend&gt;Javacript Return Confirm&lt;/legend&gt;
&lt;p&gt;&lt;label for=&quot;email&quot;&gt;E-mail:&lt;/label&gt;&lt;br /&gt;
&lt;input id=&quot;emailJS&quot; type=&quot;text&quot; name=&quot;emailJS&quot; value=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
</pre>
<p>And you get something that looks like this:<br />
<img src="http://jensbits.com/images/js-JS-FormSubmit.gif" alt="javascript confirm box" /></p>
<p>Low overhead, not too much strain on the brain but pretty plain vanilla. And boring. Let&#8217;s do something a little fancier.</p>
<h2>jQuery UI</h2>
<p>The <a href="http://jqueryui.com/">jQuery UI library</a> is awesome. Loads of flexibility and customization available and they hand you everything you need. For this solution we have to load in an additional stylesheet (you can <a href="http://jqueryui.com/themeroller/">download a custom ready-made css</a>), the jQuery base js, and the jQuery UI js. The jQuery UI site allows you to customize its js file to include only the parts you will use.</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/blitzer/jquery-ui-1.8.2.custom.css&quot;&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-ui-1.8.2.custom.min.js&quot;&gt;&lt;/script&gt;
</pre>
<p>The form is untouched for this approach, but we do have to add some js to the document itself and an additional div element that will hold the contents of our modal box.</p>
<p>Here the we set some parameters for the dialog box including what the buttons should say and do. Then a little jQuery is added so that the e-mail is displayed in the box and the box opens on submit allowing the user to hit the &#8216;Submit&#8217; button or the enter key.</p>
<pre class="brush: jscript;">
        $(function(){
                // jQuery UI Dialog    

                $('#dialog').dialog({
                    autoOpen: false,
                    width: 400,
                    modal: true,
                    resizable: false,
                    buttons: {
                        &quot;Submit Form&quot;: function() {
                            document.testconfirmJQ.submit();
                        },
                        &quot;Cancel&quot;: function() {
                            $(this).dialog(&quot;close&quot;);
                        }
                    }
                });

                $('form#testconfirmJQ').submit(function(){
                    $(&quot;p#dialog-email&quot;).html($(&quot;input#emailJQ&quot;).val());
                    $('#dialog').dialog('open');
                    return false;
                });
        });
</pre>
<p>The form is pretty clean and the div containing the text for the dialog box can be placed anywhere on the page.</p>
<pre class="brush: xml;">

&lt;form id=&quot;testconfirmJQ&quot; name=&quot;testconfirmJQ&quot; method=&quot;post&quot;&gt;
&lt;fieldset&gt;
&lt;legend&gt;jQuery UI Modal Submit&lt;/legend&gt;
&lt;p&gt;&lt;label for=&quot;email&quot;&gt;E-mail:&lt;/label&gt;&lt;br /&gt;
&lt;input id=&quot;emailJQ&quot; type=&quot;text&quot; name=&quot;emailJQ&quot; value=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/form&gt;

&lt;div id=&quot;dialog&quot; title=&quot;Verify Form jQuery UI Style&quot;&gt;&lt;p&gt;&lt;span class=&quot;ui-icon ui-icon-alert&quot; style=&quot;float:left; margin:0 7px 0 0;&quot;&gt;&lt;/span&gt; You entered your e-mail address as:&lt;/p&gt;&lt;p id=&quot;dialog-email&quot;&gt;&lt;/p&gt;&lt;p&gt;
If this is correct, click Submit Form.&lt;/p&gt;&lt;p&gt;To edit, click Cancel.&lt;p&gt;&lt;/div&gt;
</pre>
<p>Using this method you get a much prettier result:<br />
<img src="http://jensbits.com/images/js-JQ-UI-FormSubmit.gif" alt="jQuery dialog box" /></p>
<h2>Thickbox method</h2>
<p>The <a href="http://jquery.com/demo/thickbox/">ever helpful and massively adaptable Thickbox</a> was easily coded to do this as well. Thickbox also requires its own stylesheet and js along with the base jQuery file. Many apps have this already loaded since Thickbox is so wildly popular.</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/thickbox.css&quot;&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/thickbox-compressed.js&quot;&gt;&lt;/script&gt;
</pre>
<p>As with the jQuery UI method, we add some js to the document to put in the e-mail from the form, open the Thickbox, and instruct the buttons on what actions to take when clicked.</p>
<pre class="brush: jscript;">
        $(function(){
                //Thickbox

                $('form#testconfirmTB').submit(function(){
                    $(&quot;p#TB-email&quot;).html($(&quot;input#emailTB&quot;).val());
                    tb_show('Verify Form Thickbox Style','TB_inline?height=155&amp;amp;width=300&amp;amp;inlineId=TBcontent');
                    return false;
                });

                $('input#TBcancel').click(function(){
                    tb_remove();
                });

                $('input#TBsubmit').click(function(){
                    document.testconfirmTB.submit();
                });
        });
</pre>
<p>The form is also clean for this method and a div is added for the Thickbox content.</p>
<pre class="brush: xml;">
&lt;form id=&quot;testconfirmTB&quot; name=&quot;testconfirmTB&quot; method=&quot;post&quot;&gt;
&lt;fieldset&gt;
&lt;legend&gt;Thickbox Modal Submit&lt;/legend&gt;
&lt;p&gt;&lt;label for=&quot;email&quot;&gt;E-mail:&lt;/label&gt;&lt;br /&gt;
&lt;input id=&quot;emailTB&quot; type=&quot;text&quot; name=&quot;emailTB&quot; value=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/p&gt;

&lt;/fieldset&gt;
&lt;/form&gt;

&lt;div id=&quot;TBcontent&quot; style=&quot;display: none;&quot;&gt;&lt;p&gt;You entered your e-mail address as:&lt;/p&gt;&lt;p id=&quot;TB-email&quot;&gt;&lt;/p&gt;&lt;p&gt;
If this is correct, click Submit Form.&lt;/p&gt;&lt;p&gt;To edit, click Cancel.&lt;p&gt;
&lt;input type=&quot;submit&quot; id=&quot;TBcancel&quot; value=&quot;Cancel&quot; /&gt;
&lt;input type=&quot;submit&quot; id=&quot;TBsubmit&quot; value=&quot;Submit Form&quot; /&gt;
&lt;/div&gt;
</pre>
<p>The Thickbox, generically styled (the default styling actually), looks like this:<br />
<img src="http://jensbits.com/images/js-TB-FormSubmit.gif" alt="Thickbox modal confirm box" /></p>
<p>Three flavors for confirming on form submission. Enjoy.</p>
<h2>Recommended:</h2>
<div style="height:250px;">
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0596159773" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=1935182323" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0980576857" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0321509021" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
</div>
<p id="demo"><a href="/demos/forms/index.php"><span>Demo</span></a></p>
<p id="download"><a href="/media/code/modal-confirm.zip"><span>Download zip of all files</span></a></p>
<p class="donate">If this post helped you out, please consider donating to help pay the hosting fees. 100% of the donations go to the web host.</p>

<!-- Begin PayPal Donations by http://wpstorm.net/ -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="jen@jensbits.com" /><input type="hidden" name="return" value="http://www.jensbits.com/thank-you/" /><input type="hidden" name="item_name" value="Help pay hosting. All donations go to hosting fees for this site." /><input type="hidden" name="currency_code" value="USD" /><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
<!-- End PayPal Donations -->



<p>Related posts:<ol><li><a href='http://www.jensbits.com/2009/10/23/jquery-ajax-and-jquery-post-form-submit-examples-with-coldfusion/' rel='bookmark' title='Permanent Link: jQuery.ajax and jQuery.post Form Submit Examples with ColdFusion'>jQuery.ajax and jQuery.post Form Submit Examples with ColdFusion</a></li>
<li><a href='http://www.jensbits.com/2009/10/04/jquery-ajax-and-jquery-post-form-submit-examples-with-php/' rel='bookmark' title='Permanent Link: jQuery.ajax and jQuery.post Form Submit Examples with PHP'>jQuery.ajax and jQuery.post Form Submit Examples with PHP</a></li>
<li><a href='http://www.jensbits.com/2010/06/16/jquery-modal-dialog-close-on-overlay-click/' rel='bookmark' title='Permanent Link: jQuery Modal Dialog Close on Overlay Click'>jQuery Modal Dialog Close on Overlay Click</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jensbits.com/2009/08/10/modal-confirmation-dialog-on-form-submit-javascript-jquery-ui-and-thickbox-varieties/feed/</wfw:commentRss>
		<slash:comments>75</slash:comments>
		</item>
		<item>
		<title>Test Drivin&#8217; Safari 4</title>
		<link>http://www.jensbits.com/2009/06/14/test-drivin-safari-4/</link>
		<comments>http://www.jensbits.com/2009/06/14/test-drivin-safari-4/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 14:04:02 +0000</pubDate>
		<dc:creator>jen</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.jensbits.com/?p=225</guid>
		<description><![CDATA[I gave Safari 4 a whirl on both Mac and PC. I like it. It brings much of the cool stuff from iTunes into the browser. Cover flow is fun and fresh in a browser. The Top Sites with the page previews is an upscale rip off of Chrome and, really, it&#8217;s a good feature [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I gave Safari 4 a whirl on both Mac and PC. I like it. It brings much of the cool stuff from iTunes into the browser. Cover flow is fun and fresh in a browser. The Top Sites with the page previews is an upscale rip off of Chrome and, really, it&#8217;s a good feature for any browser.</p>
<div>
<div>
<strong>Cover Flow</strong><br />
<img src="http://jensbits.com/images/coverflow.jpg" alt="Safari Cover Flow" />
</div>
<div>
<strong>Top Sites</strong><br />
<img src="http://jensbits.com/images/topcontent.jpg" alt="Safari Top Sites" />
</div>
</div>
<p>Safari 4 is great for casual browsing and general perusing of the code but web development work stills needs the robustness of the Firefox plugins. Firefox is so ahead of the curve for web developers and I&#8217;m so used to it&#8217;s fantastic toolbars and debuggers that I don&#8217;t know if anyone will catch up. Granted the Safari 4 Web Inspector on the pre-packed Developer toolbar is nifty. Gotta love the &#8216;Resources&#8217; tab. Nice visual of the weight of each loaded item. The included scripts debugger is handy and  a much needed accessory in every browser.</p>
<p>Did I mention Safari 4 is fast? It is. That my biggest complaint with Firefox. It can be slow to render. Maybe that will improve with FF 3.5. Still, the trade off at this point is worth it. Bottom line is Safari 4 is great for browsing and the Web Inspector is a must &#8216;once over&#8217; tool for developers.</p>
<p>FYI, Lifehacker has a <a href="http://lifehacker.com/5286869/lifehacker-speed-tests-safari-4-chrome-2-and-more">great article on the latest browser speed tests</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jensbits.com/2009/06/14/test-drivin-safari-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Analytics API Login Authentication with ColdFusion</title>
		<link>http://www.jensbits.com/2009/05/10/google-analytics-api-login-authentication-with-coldfusion/</link>
		<comments>http://www.jensbits.com/2009/05/10/google-analytics-api-login-authentication-with-coldfusion/#comments</comments>
		<pubDate>Sun, 10 May 2009 23:43:46 +0000</pubDate>
		<dc:creator>jen</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.jensbits.com/?p=123</guid>
		<description><![CDATA[You might also like the ColdFusion and Google Analytics: Getting Out What You Put In post. Updated 08-02-2009: Replaced this line: &#60;cfset accountXML = callApi(&#34;https://www.google.com/analytics/feeds/accounts/#urlEncodedFormat(form.Email)#&#34;,loginAuth) /&#62; with this: &#60;cfset accountXML = callApi(&#34;https://www.google.com/analytics/feeds/accounts/default&#34;,loginAuth) /&#62; My Hooking into Google Analytics with ColdFusion post received a suggestion from Raymond Camden that authentication and token acquisition could be done [...]


Related posts:<ol><li><a href='http://www.jensbits.com/2009/12/19/coldfusion-and-google-analytics-getting-out-what-you-put-in/' rel='bookmark' title='Permanent Link: ColdFusion and Google Analytics: Getting Out What You Put In'>ColdFusion and Google Analytics: Getting Out What You Put In</a></li>
<li><a href='http://www.jensbits.com/2009/05/02/hooking-into-google-analytics-with-coldfusion/' rel='bookmark' title='Permanent Link: Hooking into Google Analytics with ColdFusion'>Hooking into Google Analytics with ColdFusion</a></li>
<li><a href='http://www.jensbits.com/2010/05/16/generating-signatures-in-coldfusion-with-rsa-sha1-for-secure-authsub-in-google-analytics/' rel='bookmark' title='Permanent Link: Generating Signatures in ColdFusion with RSA-SHA1 for Secure AuthSub in Google Analytics'>Generating Signatures in ColdFusion with RSA-SHA1 for Secure AuthSub in Google Analytics</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p>You might also like the <a href="/2009/12/19/coldfusion-and-google-analytics-getting-out-what-you-put-in/">ColdFusion and Google Analytics: Getting Out What You Put In</a> post.</p></blockquote>
<p><strong>Updated 08-02-2009:</strong> Replaced this line:</p>
<pre class="brush: coldfusion;">
&lt;cfset accountXML = callApi(&quot;https://www.google.com/analytics/feeds/accounts/#urlEncodedFormat(form.Email)#&quot;,loginAuth) /&gt;
</pre>
<p>with this:</p>
<pre class="brush: coldfusion;">
&lt;cfset accountXML = callApi(&quot;https://www.google.com/analytics/feeds/accounts/default&quot;,loginAuth) /&gt;
</pre>
<p>My <a href="/2009/05/02/hooking-into-google-analytics-with-coldfusion/">Hooking into Google Analytics with ColdFusion post</a> received a suggestion from Raymond Camden that authentication and token acquisition could be done via cfhttp for access to Google Analytics information. So, here it is again with authentication built in. I set this up with a email/password form but you could easily hard code the email and password in if you so desired.</p>
<p>1. Prompt for email and password of Google account that has access to Google Analytics data. This is an all-in-one example so the form submits back to its own page and processing continues.</p>
<pre class="brush: xml;">
&lt;form action=&quot;GAwithCFlogin.cfm&quot; method=&quot;post&quot;&gt;
Google email &lt;input type=&quot;text&quot; name=&quot;Email&quot; /&gt;&lt;br /&gt;
Password &lt;input type=&quot;password&quot; name=&quot;password&quot; /&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>2. Authenticate the credentials with Google.</p>
<pre class="brush: coldfusion;">
&lt;cfset loginAuth = googleLogin(form.Email,form.password) /&gt;
</pre>
<p>The googleLogin function sends the email/password combo along with the service and source values as URL parameters required by Google to Google&#8217;s client login URL via a post request. The source parameter is a <em>Short string identifying your application, for logging purposes. This string should take the form: &#8220;companyName-applicationName-versionID&#8221;</em>  according to Google. You can put in your company name or whatever name you want followed by the rest of the convention Google suggests. Example: yourcompanyname-analytics-1.0. The default start and end dates are also set here.</p>
<pre class="brush: coldfusion;">
&lt;!---dates for one full year of stats (default)---&gt;
&lt;cfset startdate = DateFormat(DateAdd(&quot;d&quot;,-365,CreateDate(Year(Now()),Month(Now()),Day(Now()))), &quot;yyyy-mm-dd&quot;) /&gt;
&lt;cfset enddate = DateFormat(DateAdd(&quot;d&quot;, -1, Now()),&quot;yyyy-mm-dd&quot;) /&gt;

&lt;cffunction name=&quot;googleLogin&quot; access=&quot;public&quot; returntype=&quot;string&quot;&gt;
	&lt;cfargument name=&quot;email&quot; type=&quot;string&quot; required=&quot;yes&quot; default=&quot;&quot;&gt;
	&lt;cfargument name=&quot;password&quot; type=&quot;string&quot;required=&quot;yes&quot; default=&quot;&quot;&gt;
    &lt;cfargument name=&quot;gaLoginUrl&quot; type=&quot;string&quot; required=&quot;no&quot; default=&quot;https://www.google.com/accounts/ClientLogin&quot;&gt;

    &lt;cfset var loginAuth = &quot;&quot; /&gt;

    &lt;cfhttp url=&quot;#arguments.gaLoginUrl#&quot; method=&quot;post&quot;&gt;
        &lt;cfhttpparam name=&quot;accountType&quot; type=&quot;url&quot; value=&quot;GOOGLE&quot;&gt;
        &lt;cfhttpparam name=&quot;Email&quot; type=&quot;url&quot; value=&quot;#arguments.email#&quot;&gt;
        &lt;cfhttpparam name=&quot;Passwd&quot; type=&quot;url&quot; value=&quot;#arguments.password#&quot;&gt;
        &lt;cfhttpparam name=&quot;service&quot; type=&quot;url&quot; value=&quot;analytics&quot;&gt;
        &lt;cfhttpparam name=&quot;source&quot; type=&quot;url&quot; value=&quot;yourCompanyName-analytics-1.0&quot;&gt;
    &lt;/cfhttp&gt;

	&lt;cfif NOT FindNoCase(&quot;Auth=&quot;,cfhttp.filecontent)&gt;
		&lt;cfset loginAuth = &quot;Authorization Failed&quot; /&gt;
	&lt;cfelse&gt;
		&lt;cfset loginAuth = Mid(cfhttp.filecontent, FindNoCase(&quot;Auth=&quot;,cfhttp.filecontent) + (Len(&quot;Auth=&quot;)), Len(cfhttp.filecontent)) /&gt;
	&lt;/cfif&gt;

    &lt;cfreturn loginAuth /&gt;
&lt;/cffunction&gt;
</pre>
<p>What should come back is a long string of authorization token values. There are several but we only need the Auth token. If it&#8217;s not in there, we send back &#8220;Authorization Failed.&#8221; If it&#8217;s in there, we strip it out and return it. </p>
<p>3. Get the accounts associated with the email. There can be more than one set up in Analytics.</p>
<pre class="brush: coldfusion;">
&lt;cfset accountXML = callApi(&quot;https://www.google.com/analytics/feeds/accounts/default&quot;,loginAuth) /&gt;
</pre>
<p>The email account is appended onto the Google URL and a get call is made from the callApi function with the loginAuth token attached as a header value.</p>
<pre class="brush: coldfusion;">
&lt;cffunction name=&quot;callApi&quot; access=&quot;public&quot; returntype=&quot;string&quot;&gt;
    &lt;cfargument name=&quot;gaUrl&quot; type=&quot;string&quot; required=&quot;yes&quot;&gt;
    &lt;cfargument name=&quot;authToken&quot; type=&quot;string&quot; required=&quot;yes&quot;&gt;

    &lt;cfset var authSubToken = 'GoogleLogin auth=' &amp; arguments.authToken /&gt;
    &lt;cfset var responseOutput = &quot;&quot; /&gt;

    &lt;cfhttp url=&quot;#arguments.gaUrl#&quot; method=&quot;get&quot;&gt;
        &lt;cfhttpparam name=&quot;Authorization&quot; type=&quot;header&quot; value=&quot;#authSubToken#&quot;&gt;
    &lt;/cfhttp&gt;

    &lt;cfset responseOutput = cfhttp.filecontent /&gt;

    &lt;cfreturn responseOutput /&gt;
&lt;/cffunction&gt;
</pre>
<p>The header value must be in the form of Authentication: GoogleLogin auth=DF3843483&#8230;(<em>it&#8217;s kind of long but you get the idea</em>). This authentication is different form AuthSub Proxy authentication used in my previous post.</p>
<p>4. Clean up the XML that returned so we can use XmlSearch() and other handy functions available in ColdFusion. For some reason the atom specification of the XML file bungles those functions up. We need to remove the xmlns nodes from the feed element and remove the dxp prefixes. Do a cfdump on the XML before and after two lines of code used to tidy them up to seed what happens. </p>
<pre class="brush: coldfusion;">
&lt;cfdump var=&quot;#accountXML#&quot;&gt;
</pre>
<p>Then roll through the accountXML with to grab all the profiles and toss them into an array so we can loop through them later.</p>
<pre class="brush: coldfusion;">
&lt;!---remove dxp: prefix from nodes that have it---&gt;
	&lt;cfset accountXML = accountXML.ReplaceAll(&quot;(&lt;/?)(\w+:)&quot;,&quot;$1&quot;) /&gt;
	&lt;!---Strip xmlns from feed element---&gt;
	&lt;cfset accountXML = REReplaceNoCase(accountXML,&quot;&lt;feed[^&gt;]*&gt;&quot;,&quot;&lt;feed&gt;&quot;) /&gt;

	&lt;cfset entryNodes = XmlSearch(accountXML, '//entry/') /&gt;

	&lt;cfset profileArray = ArrayNew(1) /&gt;

	&lt;cfloop from=&quot;1&quot; to=&quot;#ArrayLen(entryNodes)#&quot; index=&quot;num&quot;&gt;
		&lt;cfset entryStruct = StructNew() /&gt;

		&lt;cfset entryStruct.id = entryNodes[num].id.XmlText /&gt;
		&lt;cfset entryStruct.title = entryNodes[num].title.XmlText /&gt;
		&lt;cfset entryStruct.tableId = entryNodes[num].tableId.XmlText /&gt;

		&lt;cfloop from=&quot;1&quot; to=&quot;#ArrayLen(entryNodes[num].property)#&quot; index=&quot;i&quot;&gt;
   			&lt;cfswitch expression='#entryNodes[num].property[i].XmlAttributes[&quot;name&quot;]#'&gt;
    		    &lt;cfcase value=&quot;ga:accountId&quot;&gt;
       		     &lt;cfset entryStruct.accountId = entryNodes[num].property[i].XmlAttributes[&quot;value&quot;] /&gt;
     		   &lt;/cfcase&gt;
      		  &lt;cfcase value=&quot;ga:accountName&quot;&gt;
    		        &lt;cfset entryStruct.accountName = entryNodes[num].property[i].XmlAttributes[&quot;value&quot;] /&gt;
 		       &lt;/cfcase&gt;
		         &lt;cfcase value=&quot;ga:profileId&quot;&gt;
		               &lt;cfset entryStruct.profileId = entryNodes[num].property[i].XmlAttributes[&quot;value&quot;] /&gt;
	            &lt;/cfcase&gt;
	            &lt;cfcase value=&quot;ga:webPropertyId&quot;&gt;
	                &lt;cfset entryStruct.webPropertyId = entryNodes[num].property[i].XmlAttributes[&quot;value&quot;] /&gt;
	            &lt;/cfcase&gt;
	        &lt;/cfswitch&gt;
	    &lt;/cfloop&gt;

		    &lt;cfset arrayAppend(profileArray,duplicate(entryStruct)) /&gt;

		&lt;/cfloop&gt;
</pre>
<p>5. Loop through the profiles, grab the page views and visitors, and tally them up for all profiles.</p>
<pre class="brush: coldfusion;">
&lt;cfset totalpageviews = 0 /&gt;
&lt;cfset totalvisitors = 0 /&gt;

		&lt;cfloop from=&quot;1&quot; to=&quot;#ArrayLen(profileArray)#&quot; index=&quot;num&quot;&gt;
	    	&lt;cfset reqUrl = &quot;https://www.google.com/analytics/feeds/data?ids=&quot; &amp; profileArray[num].tableId &amp; &quot;&amp;metrics=ga:pageviews,ga:visitors&amp;start-date=&quot; &amp; startdate &amp; &quot;&amp;end-date=&quot; &amp; enddate /&gt;

	 		 &lt;cfset statsXML = callApi(reqUrl,loginAuth) /&gt;
	                &lt;!---Tidy up the XML again ---&gt;
	 		 &lt;cfset statsXML = statsXML.ReplaceAll(&quot;(&lt;/?)(\w+:)&quot;,&quot;$1&quot;) /&gt;
			 &lt;cfset statsXML = REReplaceNoCase(statsXML,&quot;&lt;feed[^&gt;]*&gt;&quot;,&quot;&lt;feed&gt;&quot;) /&gt;

			 &lt;cfset metric = XmlSearch(statsXML, '//metric/') /&gt;

			 &lt;cfset pageviews = metric[1].XmlAttributes[&quot;value&quot;] /&gt;

                         &lt;cfset visitors = metric[2].XmlAttributes[&quot;value&quot;] /&gt;

			 &lt;cfset totalpageviews = totalpageviews + pageviews /&gt;

                         &lt;cfset totalvisitors = totalvisitors + visitors /&gt;

			 &lt;p&gt;&lt;strong&gt;Profile:&lt;/strong&gt; &lt;em&gt;#profileArray[num].title#&lt;/em&gt; Pageviews: #NumberFormat(pageviews, &quot;,&quot;)# Visitors: #NumberFormat(visitors, &quot;,&quot;)# &lt;/p&gt;

		 &lt;/cfloop&gt;

		&lt;p&gt;&lt;strong&gt;Total pageviews:&lt;/strong&gt; #NumberFormat(totalpageviews, &quot;,&quot;)#&lt;/p&gt;
                &lt;p&gt;&lt;strong&gt;Total visitors:&lt;/strong&gt; #NumberFormat(totalvisitors, &quot;,&quot;)#&lt;/p&gt;
</pre>
<p>All done. Thank you Raymond Camden and Alex Curelea. Alex got me pointed in the right direction with his post <a href="http://www.alexc.me/using-the-google-analytics-api-getting-total-number-of-page-views/">Using the Google Analytics API &#8211; getting total number of page views</a>. And, as I mentioned at the get go, <a href="http://www.coldfusionjedi.com/">Raymond Camden</a> made the suggestion of using the login as some of his examples have done in the past.</p>
<h2>Recommended Reading</h2>
<div style="height: 250px;">
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0470529393" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0470130652" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0470562315" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<div style="float:left;margin-right: 25px">
<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=jensbits-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0470531282" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
</div>
<p id="demo"><a href="http://cf-jensbits.com/demos/ga_apilogin/" onclick="_gaq.push(['_link', 'http://cf-jensbits.com/demos/ga_apilogin/']); return false;"><span>Demo</span></a></p>
<p id="download"><a href="/media/GAwithCFlogin.txt"><span>Download</span></a></p>
<p>Information on <a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Request">Google&#8217;s Authentication for Installed Application ClientLogin</a> and the <a href="http://code.google.com/apis/analytics/docs/gdata/1.0/gdataProtocol.html#ClientLogin">Google Analytics Data API ClientLogin Username/Password Authentication</a>.</p>
<p>Helpful ColdFusion books include the all-in-one <a href="http://www.amazon.com/gp/product/0321223675?ie=UTF8&#038;tag=jensbits-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321223675">ColdFusion MX 7 WACK</a><img src="http://www.assoc-amazon.com/e/ir?t=jensbits-20&#038;l=as2&#038;o=1&#038;a=0321223675" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> with tons of good information even if you&#8217;ve moved up to CF8. Crazy as it seems, Adobe decided to break up ColdFusion 8 books into three volumes: <a href="http://www.amazon.com/gp/product/032151548X?ie=UTF8&#038;tag=jensbits-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=032151548X">Volume 1: Getting Started</a><img src="http://www.assoc-amazon.com/e/ir?t=jensbits-20&#038;l=as2&#038;o=1&#038;a=032151548X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, <a href="http://www.amazon.com/gp/product/0321515463?ie=UTF8&#038;tag=jensbits-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321515463">Volume 2: Application Development</a><img src="http://www.assoc-amazon.com/e/ir?t=jensbits-20&#038;l=as2&#038;o=1&#038;a=0321515463" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, and <a href="http://www.amazon.com/gp/product/0321515471?ie=UTF8&#038;tag=jensbits-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321515471">Volume 3: Advanced Application Development</a><img src="http://www.assoc-amazon.com/e/ir?t=jensbits-20&#038;l=as2&#038;o=1&#038;a=0321515471" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. You may be able to pick up a used copy in good condition. Follow the book link to Amazon and look for used copies underneath the books title.</p>


<p>Related posts:<ol><li><a href='http://www.jensbits.com/2009/12/19/coldfusion-and-google-analytics-getting-out-what-you-put-in/' rel='bookmark' title='Permanent Link: ColdFusion and Google Analytics: Getting Out What You Put In'>ColdFusion and Google Analytics: Getting Out What You Put In</a></li>
<li><a href='http://www.jensbits.com/2009/05/02/hooking-into-google-analytics-with-coldfusion/' rel='bookmark' title='Permanent Link: Hooking into Google Analytics with ColdFusion'>Hooking into Google Analytics with ColdFusion</a></li>
<li><a href='http://www.jensbits.com/2010/05/16/generating-signatures-in-coldfusion-with-rsa-sha1-for-secure-authsub-in-google-analytics/' rel='bookmark' title='Permanent Link: Generating Signatures in ColdFusion with RSA-SHA1 for Secure AuthSub in Google Analytics'>Generating Signatures in ColdFusion with RSA-SHA1 for Secure AuthSub in Google Analytics</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jensbits.com/2009/05/10/google-analytics-api-login-authentication-with-coldfusion/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Latest mag obsession &#8220;Practical Web Design&#8221; aka &#8220;.net&#8221;</title>
		<link>http://www.jensbits.com/2008/10/29/latest-mag-obsession-practical-web-design-aka-net/</link>
		<comments>http://www.jensbits.com/2008/10/29/latest-mag-obsession-practical-web-design-aka-net/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 22:18:34 +0000</pubDate>
		<dc:creator>jen</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.jensbits.com/2008/10/29/latest-mag-obsession-practical-web-design-aka-net/</guid>
		<description><![CDATA[I have to hand to the Brits; they are into web design and standardization like nobody&#8217;s business. Web design and development is a moving target. I have been to the expensive conferences and events. Loads of great and inspiring info. Problem is you need something that you can refer back to and use as a [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have to hand to the Brits; they are into web design and standardization like nobody&#8217;s business. Web design and development is a moving target. I have been to the expensive conferences and events. Loads of great and inspiring info. Problem is you need something that you can refer back to and use as a resource. And, something that is here and now, tangible, tactile, and moving as fast as web evolution itself. I&#8217;m talking mags.<br />
<a href="http://www.netmag.co.uk/"><img class="photo-r" src="http://jensbits.com/images/netmag.gif" alt=".net mag" /></a><br />
I got my hands on a copy of the UK produced and published <a href="http://www.amazon.com/gp/product/B00007KZJ2?ie=UTF8&#038;tag=jensbits-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=B00007KZJ2">&#8220;Practical Web Design&#8221; (known as &#8220;.net&#8221; in Great Britain)</a><img src="http://www.assoc-amazon.com/e/ir?t=jensbits-20&#038;l=as2&#038;o=1&#038;a=B00007KZJ2" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> magazine at Borders and have read every word twice. It&#8217;s like carrying around the enthusiasm and electricity of a conference in my pocket(book). This is what web designers need. A constant flow of practical and applicable information. It keeps you motivated and relevant. It doesn&#8217;t hurt that I have met many of the contributors and advisory panels members at the aforementioned conferences. They are picking the top and, IMHO, the most credible talent to fill the pages.</p>
<p>Now for the bad news. It&#8217;s expensive here in the US (over $130/yr) at the current exchange rate. I&#8217;ll keeping picking it up a copy at a time to spread out the pain, but I love it anyway.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jensbits.com/2008/10/29/latest-mag-obsession-practical-web-design-aka-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
