<?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>Çağlayan Yıldırım - ceYe &#187; google analytics</title>
	<atom:link href="http://www.caglayanyildirim.com/tag/google-analytics/feed" rel="self" type="application/rss+xml" />
	<link>http://www.caglayanyildirim.com</link>
	<description>Programlama, kişisel, fotoğraf vs...</description>
	<lastBuildDate>Mon, 30 Nov 2009 15:45:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google Analytics için Asp.NET WebControl</title>
		<link>http://www.caglayanyildirim.com/google-analytics-icin-asp-net-webcontrol</link>
		<comments>http://www.caglayanyildirim.com/google-analytics-icin-asp-net-webcontrol#comments</comments>
		<pubDate>Wed, 25 Nov 2009 16:19:48 +0000</pubDate>
		<dc:creator>ceYe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Çağlayan Yıldırım]]></category>
		<category><![CDATA[ceye]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[Web Control]]></category>

		<guid isPermaLink="false">http://www.caglayanyildirim.com/?p=15</guid>
		<description><![CDATA[Google Analytics Özelliğini ASP.NET WebSitenize ekleyebilmeniz için kolaylık sağlayacak bir WebControl.
Bu WebControl ile 2 Analytics Mod&#8217;unu da kullanabilirsiniz;

Analytics GA
Analytics Urchin

Code :

[DefaultProperty(&#34;Text&#34;)]
[ToolboxData(&#34;&#60;{0}:GoogleAnalytics runat=server&#62;&#60;/{0}:GoogleAnalytics&#62;&#34;)]
public class GoogleAnalytics : Control
{
    #region Inner Enum

    public enum AnalyticMode
    {
        Urchin,
      [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.caglayanyildirim.com/tag/google-analytics" class="st_tag internal_tag" rel="tag" title="Posts tagged with google analytics">Google Analytics</a> Özelliğini <a href="http://www.caglayanyildirim.com/tag/asp-net" class="st_tag internal_tag" rel="tag" title="Posts tagged with ASP.NET">ASP.NET</a> WebSitenize ekleyebilmeniz için kolaylık sağlayacak bir WebControl.</p>
<p>Bu WebControl ile 2 Analytics Mod&#8217;unu da kullanabilirsiniz;</p>
<ul>
<li>Analytics GA</li>
<li>Analytics Urchin</li>
</ul>
<h3>Code :</h3>
<pre class="brush: csharp;">
[DefaultProperty(&quot;Text&quot;)]
[ToolboxData(&quot;&lt;{0}:GoogleAnalytics runat=server&gt;&lt;/{0}:GoogleAnalytics&gt;&quot;)]
public class GoogleAnalytics : Control
{
    #region Inner Enum

    public enum AnalyticMode
    {
        Urchin,
        GA
    }

    #endregion

    #region Public Properties

    public String UACode
    {
        get { return ViewState[&quot;UACode&quot;] as String; }
        set { ViewState[&quot;UACode&quot;] = value; }
    }
    public AnalyticMode GMode
    {
        get { return (AnalyticMode)ViewState[&quot;Mode&quot;]; }
        set { ViewState[&quot;Mode&quot;] = value; }
    }

    #endregion

    #region Protected Overrides Methods

    protected override void Render(HtmlTextWriter output)
    {
        switch (GMode)
        {
            case AnalyticMode.GA:
                output.Write(GetGAString());
                break;
            case AnalyticMode.Urchin:
                output.Write(GetUrchinString());
                break;
            default:
                output.Write(GetGAString());
                break;
        }
    }

    #endregion

    #region Private Methods

    private String GetUrchinString()
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine(&quot;&lt;script src=\&quot;http://www.google-analytics.com/urchin.js\&quot; type=\&quot;text/javascript\&quot;&gt;&quot;);
        sb.AppendLine(&quot;&lt;/script&gt;&quot;);
        sb.AppendLine(&quot;&lt;script type=\&quot;text/javascript\&quot;&gt;&quot;);
        sb.AppendLine(&quot;_uacct = \&quot;&quot; + UACode + &quot;\&quot;;&quot;);
        sb.AppendLine(&quot;urchinTracker();&quot;);
        sb.AppendLine(&quot;&lt;/script&gt;&quot;);
        return sb.ToString();
    }

    private String GetGAString()
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine(&quot;&lt;script type=\&quot;text/javascript\&quot;&gt;&quot;);
        sb.AppendLine(&quot;var gaJsHost = ((\&quot;https:\&quot; == document.location.protocol) ? \&quot;https://ssl.\&quot; : \&quot;http://www.\&quot;);&quot;);
        sb.AppendLine(&quot;document.write(unescape(\&quot;%3Cscript src='\&quot; + gaJsHost + \&quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\&quot;));&quot;);
        sb.AppendLine(&quot;&lt;/script&gt;&quot;);
        sb.AppendLine(&quot;&lt;script type=\&quot;text/javascript\&quot;&gt;&quot;);
        sb.AppendLine(&quot;var pageTracker = _gat._getTracker(\&quot;&quot; + UACode + &quot;\&quot;);&quot;);
        sb.AppendLine(&quot;pageTracker._initData();&quot;);
        sb.AppendLine(&quot;pageTracker._trackPageview();&quot;);
        sb.AppendLine(&quot;&lt;/script&gt;&quot;);
        return sb.ToString();
    }

    #endregion
}
</pre>
<h3>Kullanılışı:</h3>
<pre class="brush: csharp;">

&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Test.aspx.cs&quot; Inherits=&quot;WebTest.WebForm.Forms.Test&quot; %&gt;

&lt;%@ Register assembly=&quot;WebTest.WebForm.Forms&quot; namespace=&quot;WebTest.WebForm.Forms&quot; tagprefix=&quot;cc1&quot; %&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head runat=&quot;server&quot;&gt;
    &lt;title&gt;Untitled Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
    &lt;div&gt;

        &lt;cc1:GoogleAnalytics ID=&quot;GoogleAnalytics1&quot; runat=&quot;server&quot;&gt;
        &lt;/cc1:GoogleAnalytics&gt;

    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.caglayanyildirim.com/google-analytics-icin-asp-net-webcontrol/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
