<?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>學習筆記 &#8211; 任姓人妻 の 生活紀錄</title>
	<atom:link href="https://blog.cindygirl.cc/archives/category/learn/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.cindygirl.cc</link>
	<description>我是冠冠，於2015年1月1日正式成為人妻，在此紀錄婚後的點點滴滴。</description>
	<lastBuildDate>Tue, 24 Mar 2020 02:15:46 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>透過 ajax傳遞 checkbox:checked 陣列 &#038; codeigniter Controller 接值</title>
		<link>https://blog.cindygirl.cc/archives/8664/%e9%80%8f%e9%81%8e-ajax%e5%82%b3%e9%81%9e-checkboxchecked-%e9%99%a3%e5%88%97-codeigniter-controller-%e6%8e%a5%e5%80%bc/</link>
					<comments>https://blog.cindygirl.cc/archives/8664/%e9%80%8f%e9%81%8e-ajax%e5%82%b3%e9%81%9e-checkboxchecked-%e9%99%a3%e5%88%97-codeigniter-controller-%e6%8e%a5%e5%80%bc/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Fri, 20 Mar 2020 07:55:13 +0000</pubDate>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8664</guid>

					<description><![CDATA[<p>ajax 設定 FormData() 傳遞陣列  &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8664/%e9%80%8f%e9%81%8e-ajax%e5%82%b3%e9%81%9e-checkboxchecked-%e9%99%a3%e5%88%97-codeigniter-controller-%e6%8e%a5%e5%80%bc/">透過 ajax傳遞 checkbox:checked 陣列 &#038; codeigniter Controller 接值</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3><b>ajax 設定 FormData() 傳遞陣列</b></h3>
<blockquote>
<div>  // 1. 取得勾選項目</div>
<div>        var items = [];</div>
<div>        $.each($(&#8220;.select-export:checked&#8221;), function(){</div>
<div>            items.push($(this).val());</div>
<div>        });</div>
<div>            var form_data = new FormData();</div>
<div>            form_data.append(&#8216;ids&#8217;, items);</div>
<div></div>
<div>        // 2. 匯出</div>
<div>          $.ajax({</div>
<div>            url: &#8220;/Product/export&#8221;,</div>
<div>            type: &#8220;POST&#8221;,</div>
<div>            dataType: &#8220;text&#8221;,</div>
<div>            <span style="color: #ff0000;">data: form_data,</span></div>
<div>            contentType: false,</div>
<div>            processData: false,</div>
<div>            success: function(data) {</div>
<div></div>
<div>            },</div>
<div>            error: function(XMLHttpRequest, textStatus, errorThrown) {</div>
<div></div>
<div>            }</div>
<div>        });</div>
</blockquote>
<h3><strong>PHP Controller 接值  (use  codeigniter)</strong></h3>
<blockquote><p>$_REQUEST[&#8216;ids&#8217;];</p></blockquote>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8664/%e9%80%8f%e9%81%8e-ajax%e5%82%b3%e9%81%9e-checkboxchecked-%e9%99%a3%e5%88%97-codeigniter-controller-%e6%8e%a5%e5%80%bc/">透過 ajax傳遞 checkbox:checked 陣列 &#038; codeigniter Controller 接值</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8664/%e9%80%8f%e9%81%8e-ajax%e5%82%b3%e9%81%9e-checkboxchecked-%e9%99%a3%e5%88%97-codeigniter-controller-%e6%8e%a5%e5%80%bc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHP匯出Excel (.xls .xlsx) ，電話/手機 第一碼0會不見</title>
		<link>https://blog.cindygirl.cc/archives/8648/php%e5%8c%af%e5%87%baexcel-xls-xlsx-%ef%bc%8c%e9%9b%bb%e8%a9%b1-%e6%89%8b%e6%a9%9f-%e7%ac%ac%e4%b8%80%e7%a2%bc0%e6%9c%83%e4%b8%8d%e8%a6%8b/</link>
					<comments>https://blog.cindygirl.cc/archives/8648/php%e5%8c%af%e5%87%baexcel-xls-xlsx-%ef%bc%8c%e9%9b%bb%e8%a9%b1-%e6%89%8b%e6%a9%9f-%e7%ac%ac%e4%b8%80%e7%a2%bc0%e6%9c%83%e4%b8%8d%e8%a6%8b/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Fri, 06 Mar 2020 08:16:48 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8648</guid>

					<description><![CDATA[<p>匯出 .xls，看了前輩寫的方式是加上 等號跟雙引&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8648/php%e5%8c%af%e5%87%baexcel-xls-xlsx-%ef%bc%8c%e9%9b%bb%e8%a9%b1-%e6%89%8b%e6%a9%9f-%e7%ac%ac%e4%b8%80%e7%a2%bc0%e6%9c%83%e4%b8%8d%e8%a6%8b/">PHP匯出Excel (.xls .xlsx) ，電話/手機 第一碼0會不見</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>匯出 .xls，看了前輩寫的方式是加上 <span style="color: #ff0000;"><strong>等號跟雙引號</strong></span><br />
匯出時就能正常顯示電話號碼，0不會不見<br />
$memberPhone = <span style="color: #ff0000;">&#8216;=&#8221;&#8216;</span>.$member-&gt;phone.<span style="color: #ff0000;">&#8216;&#8221;&#8216;</span>;</p>
<p>後來改為匯出 .xlsx，發現上面的方式失效了，匯出會變成公式格式<br />
雖然點擊Excel的編輯可以正常顯示，但是如果要匯入其他介面，會讀取失敗。<br />
後來找到<a href="https://ithelp.ithome.com.tw/questions/10194852?sc=rss.qu" target="_blank" rel="noopener">其他前輩的解法</a>，加上 <span style="color: #ff0000;"><strong>\t</strong> </span>就搞定了！<br />
雖然參考的文章是針對CSV，但死馬當活馬醫，竟然也適用～<br />
$memberPhone = <span style="color: #ff0000;">&#8220;\t&#8221;</span>.$member-&gt;phone;</p>
<hr />
<p>一開始不懂 \t 的來由是啥，後來發現了<br />
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Char-Syntax.html" target="_blank" rel="noopener">原來\t 就是Tab的意思</a><br />
用Mac的Numbers打開，會發現資料前面會有一片空格<br />
但如果是用正規的Excel打開就會顯示正常～</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8648/php%e5%8c%af%e5%87%baexcel-xls-xlsx-%ef%bc%8c%e9%9b%bb%e8%a9%b1-%e6%89%8b%e6%a9%9f-%e7%ac%ac%e4%b8%80%e7%a2%bc0%e6%9c%83%e4%b8%8d%e8%a6%8b/">PHP匯出Excel (.xls .xlsx) ，電話/手機 第一碼0會不見</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8648/php%e5%8c%af%e5%87%baexcel-xls-xlsx-%ef%bc%8c%e9%9b%bb%e8%a9%b1-%e6%89%8b%e6%a9%9f-%e7%ac%ac%e4%b8%80%e7%a2%bc0%e6%9c%83%e4%b8%8d%e8%a6%8b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Google Tag Manager – SetCookie</title>
		<link>https://blog.cindygirl.cc/archives/8198/google-tag-manager-setcookie/</link>
					<comments>https://blog.cindygirl.cc/archives/8198/google-tag-manager-setcookie/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Sun, 25 Feb 2018 02:23:52 +0000</pubDate>
				<category><![CDATA[GTM]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8198</guid>

					<description><![CDATA[<p>用途說明 如果你的網站是電商平台 或者 你沒有編輯&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8198/google-tag-manager-setcookie/">Google Tag Manager – SetCookie</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h2>
	用途說明<br />
</h2>
<p>
	如果你的網站是電商平台 或者 你沒有編輯程式的權限<br />
	可是又想要利用cookie來達成某些目的，只要你會JS，就可以透過GTM來setCookie
</p>
<h2>
	設定說明<br />
</h2>
<p>
	新增一組代碼，選擇 自訂HTML，然後將 JS Code 放上去，<br />
	觸發條件(Trigger) 選擇什麼時機點要SetCookie
</p>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm_setcookie.png" style="width: 800px; height: 593px;" /></p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8198/google-tag-manager-setcookie/">Google Tag Manager – SetCookie</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8198/google-tag-manager-setcookie/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【WordPress】依 分類 呈現 最新文章</title>
		<link>https://blog.cindygirl.cc/archives/8165/wp_get_recent_posts/</link>
					<comments>https://blog.cindygirl.cc/archives/8165/wp_get_recent_posts/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Thu, 04 Jan 2018 09:11:58 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8165</guid>

					<description><![CDATA[<p>前言 一般會使用 最新文章 的小工具 但是我想要依&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8165/wp_get_recent_posts/">【WordPress】依 分類 呈現 最新文章</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>
	前言<br />
</h1>
<p>
	一般會使用 最新文章 的小工具<br />
	但是我想要依照 文章類別 各別顯示最新文章，例如下圖所示
</p>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/wordpress/wp_get_recent_posts.png" style="width: 300px; height: 355px;" />
</p>
<p>
	&nbsp;
</p>
<h1>
	程式碼<br />
</h1>
<p>
	參考<a href="https://codex.wordpress.org/Function_Reference/wp_get_recent_posts" target="_blank">官方文件</a>，使用&nbsp;wp_get_recent_posts()
</p>
<blockquote>
<pre>
//傳入參數
$args = array(
	&#39;numberposts&#39; =&gt; 3,        //要秀幾筆
	&#39;offset&#39; =&gt; 0,
	&#39;category&#39; =&gt; 4,           //分類的ID   0:不分類的最新文章
	&#39;orderby&#39; =&gt; &#39;post_date&#39;,  //排序欄位
	&#39;order&#39; =&gt; &#39;DESC&#39;,         //排序方式
	&#39;include&#39; =&gt; &#39;&#39;,
	&#39;exclude&#39; =&gt; &#39;&#39;,
	&#39;meta_key&#39; =&gt; &#39;&#39;,
	&#39;meta_value&#39; =&gt;&#39;&#39;,
	&#39;post_type&#39; =&gt; &#39;post&#39;,
	&#39;post_status&#39; =&gt; &#39;publish&#39;,   //文章狀態
	&#39;suppress_filters&#39; =&gt; true
);

//取資料
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );

//迴圈秀資料
foreach( $recent_posts as $recent ){
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;echo &#39;&lt;li&gt;&lt;a href=&quot;&#39; . get_permalink($recent["ID"]) . '">' . &nbsp; $recent["post_title"].&#39;&lt;/a&gt; &lt;/li&gt; &#39;;
}
</pre>
</blockquote>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8165/wp_get_recent_posts/">【WordPress】依 分類 呈現 最新文章</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8165/wp_get_recent_posts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Google Tag Manager – 滾軸事件</title>
		<link>https://blog.cindygirl.cc/archives/8149/google-tag-manager-%e6%bb%be%e8%bb%b8%e4%ba%8b%e4%bb%b6/</link>
					<comments>https://blog.cindygirl.cc/archives/8149/google-tag-manager-%e6%bb%be%e8%bb%b8%e4%ba%8b%e4%bb%b6/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Sun, 31 Dec 2017 15:29:21 +0000</pubDate>
				<category><![CDATA[GTM]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8149</guid>

					<description><![CDATA[<p>前言 先前要監控頁面 滾軸事件 ，需要自己貼上 J&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8149/google-tag-manager-%e6%bb%be%e8%bb%b8%e4%ba%8b%e4%bb%b6/">Google Tag Manager – 滾軸事件</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>
	前言<br />
</h1>
<p>
	先前要監控頁面 滾軸事件 ，需要自己貼上 JS Code (當然是複製別人寫好的來用)<br />
	最近有看到新文章，現在不用貼Code了，直接在GTM設定就可以了<br />
	今天剛好在做GTM案例分享，就順便測試了一下。<br />
	&nbsp;
</p>
<h2>
	Step1&nbsp; 變數 &gt; 設定，先檢查變數是否有勾選這三個項目<br />
</h2>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/scroll1.png" style="width: 550px; height: 282px;" />
</p>
<h2>
	Step2&nbsp; 設定 Triggers (觸發條件)<br />
</h2>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/scroll2.png" style="width: 550px; height: 362px;" />
</p>
<p>
	&nbsp;
</p>
<h2>
	Step3&nbsp; &nbsp;代碼 設定 GA 事件<br />
</h2>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/scroll3.png" style="width: 500px; height: 493px;" /></p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8149/google-tag-manager-%e6%bb%be%e8%bb%b8%e4%ba%8b%e4%bb%b6/">Google Tag Manager – 滾軸事件</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8149/google-tag-manager-%e6%bb%be%e8%bb%b8%e4%ba%8b%e4%bb%b6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【WordPress】固定網址</title>
		<link>https://blog.cindygirl.cc/archives/8137/wordpress_%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/</link>
					<comments>https://blog.cindygirl.cc/archives/8137/wordpress_%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Sun, 31 Dec 2017 08:55:49 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=8137</guid>

					<description><![CDATA[<p>固定網址 該怎麼選擇才好？ 以下是個人調整過很多次&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8137/wordpress_%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/">【WordPress】固定網址</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>
	固定網址 該怎麼選擇才好？<br />
</h1>
<p>
	以下是個人調整過很多次URL的心得
</p>
<p>
	一般模式：是wordpress預設的URL, 挺沒意義的，所以正常不會使用這種模式。
</p>
<p>
	日期/月份：我覺得日期跟月份也挺多餘的啦，所以不採納。
</p>
<p>
	文章模式：個人有個習慣，三不五時回顧文章時，會調整一下文章標題，如果已被搜尋引擎收錄，就會找不到此文章了！
</p>
<p>
	最後採納&nbsp; <span style="color:#FFFFFF;"><span style="background-color:#FF8C00;">文章ID + 文章標題</span></span>
</p>
<p>
	ID 就是文章的唯一值，不管我的文章標題修改N次，或者直接刪掉文章標題，都可以找到此篇文章。
</p>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/wordpress/url.png" style="width: 600px; height: 329px;" /></p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/8137/wordpress_%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/">【WordPress】固定網址</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/8137/wordpress_%e5%9b%ba%e5%ae%9a%e7%b6%b2%e5%9d%80/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【WordPress】 Duplicate Page 複製文章/複製頁面</title>
		<link>https://blog.cindygirl.cc/archives/7464/%e3%80%90wordpress%e3%80%91-duplicate-page-%e8%a4%87%e8%a3%bd%e6%96%87%e7%ab%a0%e8%a4%87%e8%a3%bd%e9%a0%81%e9%9d%a2/</link>
					<comments>https://blog.cindygirl.cc/archives/7464/%e3%80%90wordpress%e3%80%91-duplicate-page-%e8%a4%87%e8%a3%bd%e6%96%87%e7%ab%a0%e8%a4%87%e8%a3%bd%e9%a0%81%e9%9d%a2/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Tue, 05 Sep 2017 06:52:50 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=7464</guid>

					<description><![CDATA[<p>Wordpress 的文章列表、頁面列表，少了【複&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7464/%e3%80%90wordpress%e3%80%91-duplicate-page-%e8%a4%87%e8%a3%bd%e6%96%87%e7%ab%a0%e8%a4%87%e8%a3%bd%e9%a0%81%e9%9d%a2/">【WordPress】 Duplicate Page 複製文章/複製頁面</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>
	Wordpress 的文章列表、頁面列表，少了【複製】這項功能<br />
	我相信一定有外掛可以使用</p>
<p>	這個外掛說明寫得挺詳細的，我就懶得截圖了<br />
	<a href="https://tw.wordpress.org/plugins/duplicate-page/" target="_blank">https://tw.wordpress.org/plugins/duplicate-page/</a>
</p>
<p>
	​這樣相同架構的文章或頁面，透過一鍵複製就可以快速修改了。
</p>
<p>
	&nbsp;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7464/%e3%80%90wordpress%e3%80%91-duplicate-page-%e8%a4%87%e8%a3%bd%e6%96%87%e7%ab%a0%e8%a4%87%e8%a3%bd%e9%a0%81%e9%9d%a2/">【WordPress】 Duplicate Page 複製文章/複製頁面</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/7464/%e3%80%90wordpress%e3%80%91-duplicate-page-%e8%a4%87%e8%a3%bd%e6%96%87%e7%ab%a0%e8%a4%87%e8%a3%bd%e9%a0%81%e9%9d%a2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GTM – 監控 Youtube 影片點擊</title>
		<link>https://blog.cindygirl.cc/archives/7134/gtm-youtube/</link>
					<comments>https://blog.cindygirl.cc/archives/7134/gtm-youtube/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Tue, 01 Aug 2017 05:14:40 +0000</pubDate>
				<category><![CDATA[GTM]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=7134</guid>

					<description><![CDATA[<p>任務說明 記錄 Youtube 影片點擊 找了很久&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7134/gtm-youtube/">GTM – 監控 Youtube 影片點擊</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>
	任務說明<br />
</h1>
<p>
	記錄 Youtube 影片點擊<br />
	找了很久終於找到&nbsp;<a href="http://www.cardinalpath.com/youtube-video-tracking-with-google-tag-manager-v2-and-universal-analytics-a-step-by-step-guide/" target="_blank">一篇文章</a>，按照他的步驟就可以設定完畢了<br />
	看英文需要很有耐心才能仔細看完，所以我用中文重新記錄一下。<br />
	總共要設定 4個變數、2個觸發條件、2個代碼。<br />
	&nbsp;
</p>
<h1>
	設定變數 Variables<br />
</h1>
<p>
	新增「使用者定義的變數」
</p>
<h3>
	<strong><span style="color:#FF0000;">變數名稱 &nbsp;➤ YouTube is present</span></strong><br />
</h3>
<p>
	<span style="color:#000000;">複製以下程式碼，這一段判斷頁面上是否有Youtube的影片</span>
</p>
<blockquote>
<p>
		<span style="color:#000000;">// Return &quot;true&quot; if there is at least one YouTube video on the page<br />
		function () {<br />
		&nbsp; &nbsp;for (var e = document.getElementsByTagName(&#39;iframe&#39;), x = e.length; x&#8211;;)<br />
		&nbsp; &nbsp;if (/youtube.com\/embed/.test(e[x].src)){<br />
		&nbsp; &nbsp; &nbsp; return true;<br />
		&nbsp; &nbsp;}<br />
		&nbsp; &nbsp;return false;<br />
		}</span>
	</p>
</blockquote>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-1.png" style="width: 600px; height: 296px;" />
</p>
<h3>
	<strong><span style="color:#FF0000;">變數名稱 &nbsp;➤ dataLayer category</span></strong><br />
</h3>
<p>
	<span style="color:#000000;">設定GA事件時，會用到的變數。</span>
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-2.png" style="width: 600px; height: 392px;" />
</p>
<h3>
	<strong><span style="color:#FF0000;">變數名稱 &nbsp;➤ dataLayer action</span></strong><br />
</h3>
<p>
	<span style="color:#000000;">設定GA事件時，會用到的變數。</span>
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-3.png" style="width: 600px; height: 347px;" />
</p>
<h3>
	<strong><span style="color:#FF0000;">變數名稱 &nbsp;➤ dataLayer label</span></strong><br />
</h3>
<p>
	<span style="color:#000000;">設定GA事件時，會用到的變數。</span>
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-4.png" style="width: 600px; height: 383px;" />
</p>
<h1>
	設定觸發條件 &nbsp;Triggers<br />
</h1>
<h3>
	<strong><span style="color:#FF0000;">觸發條件 &nbsp;➤ Youtube event</span></strong><br />
</h3>
<p>
	這個不知道該怎解釋，我也不清楚如何作用
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-5.png" style="width: 600px; height: 361px;" />
</p>
<h3>
	<strong><span style="color:#FF0000;">觸發條件 &nbsp;➤ Youtube present</span></strong><br />
</h3>
<p>
	判斷頁面上是否有 Youtube 影片
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-6.png" style="width: 600px; height: 334px;" />
</p>
<h1>
	設定代碼 Tags<br />
</h1>
<h3>
	<span style="color:#FF0000;"><strong>代碼名稱 &nbsp;➤ YouTube Event<br />
	代碼類型&nbsp; ➤ 通用 Analytics<br />
	追蹤類型 &nbsp;➤ 事件<br />
	觸發條件 &nbsp;➤ YouTube event</strong></span><br />
</h3>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-7.png" style="width: 550px; height: 459px;" />
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-81.png" style="width: 450px; height: 413px;" />
</p>
<p>
	&nbsp;
</p>
<h3>
	<span style="color:#FF0000;"><strong>代碼名稱 &nbsp;➤&nbsp;YouTube Listener​<br />
	代碼類型&nbsp; ➤&nbsp;自訂HTML​</strong></span><br />
	<span style="color:#FF0000;"><strong>觸發條件 &nbsp;➤ YouTube present</strong></span><br />
</h3>
<p>
	複製以下程式碼<br />
	這一大段監控了很多事件, <span style="color:#0000FF;">藍色字體</span>就是監控的項目<br />
	ex. 點播放、按暫停、使用者從百分之多少開始觀看
</p>
<blockquote>
<p>
		&lt;!&#8211;<br />
		Google Analytics Tag Manager (V2) custom HTML tag for YouTube video tracking
	</p>
<p>
		Copyright 2015, Cardinal Path, Inc.
	</p>
<p>
		Original author: Stephane Hamel &lt;shamel@cardinalpath.com&gt;<br />
		Revised by: Nicky Yuen &lt;nyuen@cardinalpath.com&gt;
	</p>
<p>
		Version 1.0<br />
		&#8211;&gt;<br />
		&lt;script type=&quot;text/javascript&quot;&gt;<br />
		&nbsp;&nbsp; &nbsp;// support multiple players on the same page<br />
		&nbsp;&nbsp; &nbsp;var gtmYTPlayers = [];<br />
		&nbsp;&nbsp; &nbsp;<br />
		&nbsp; &nbsp; // OPTIONAL: Enable JSAPI if it&#39;s not already on the URL<br />
		&nbsp; &nbsp; // note: this will cause the YouTube player to &quot;flash&quot; on the page when reloading to enable the JS API<br />
		&nbsp; &nbsp; for (var e = document.getElementsByTagName(&quot;iframe&quot;), x = e.length; x&#8211;;)<br />
		&nbsp; &nbsp; &nbsp; &nbsp; if (/youtube.com\/embed/.test(e[x].src))<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (e[x].src.indexOf(&#39;enablejsapi=&#39;) === -1)<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e[x].src += (e[x].src.indexOf(&#39;?&#39;) === -1 ? &#39;?&#39; : &#39;&amp;&#39;) + &#39;enablejsapi=1&#39;;<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
		&nbsp;&nbsp; &nbsp;/**<br />
		&nbsp;&nbsp; &nbsp; * Attaches listener once the YouTube API is loaded&nbsp;&nbsp; &nbsp;<br />
		&nbsp;&nbsp; &nbsp;**/<br />
		&nbsp; &nbsp; function onYouTubeIframeAPIReady() {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; for (var e = document.getElementsByTagName(&quot;iframe&quot;), x = e.length; x&#8211;;) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (/youtube.com\/embed/.test(e[x].src)) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gtmYTPlayers.push(new YT.Player(e[x], {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; events: {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onStateChange: onPlayerStateChange,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onError: onPlayerError<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }));<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YT.gtmLastAction = &quot;p&quot;;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; }
	</p>
<p>
		&nbsp;&nbsp; &nbsp;/**<br />
		&nbsp;&nbsp; &nbsp; * Listen for play/pause. Other states such as rewind and end could also be added<br />
		&nbsp; &nbsp; &nbsp;* Also report % played every second<br />
		&nbsp;&nbsp; &nbsp; * @param e &#8211; event<br />
		&nbsp;&nbsp; &nbsp;**/<br />
		&nbsp; &nbsp; function onPlayerStateChange(e) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; e[&#8220;data&#8221;] == YT.PlayerState.PLAYING &amp;&amp; setTimeout(onPlayerPercent, 1000, e[&#8220;target&#8221;]);<br />
		&nbsp; &nbsp; &nbsp; &nbsp; var video_data = e.target[&#8220;getVideoData&#8221;](),<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label = video_data.video_id + &#39;:&#39; + video_data.title;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; if (e[&#8220;data&#8221;] == YT.PlayerState.PLAYING &amp;&amp; YT.gtmLastAction == &quot;p&quot;) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataLayer.push({<br />
		&nbsp;<span style="color:#0000FF;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event: &#39;youtube&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventCategory: &#39;youtube&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventAction: &#39;play&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventLabel: label</span><br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YT.gtmLastAction = &quot;&quot;;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; if (e[&#8220;data&#8221;] == YT.PlayerState.PAUSED) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataLayer.push({<br />
		<span style="color:#0000FF;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event: &#39;youtube&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventCategory: &#39;youtube&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventAction: &#39;pause&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventLabel: label</span><br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YT.gtmLastAction = &quot;p&quot;;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; }
	</p>
<p>
		&nbsp;&nbsp; &nbsp;/**<br />
		&nbsp;&nbsp; &nbsp; * Catch all to report errors through the GTM data layer. once the error is exposed to GTM, it can be tracked in UA as an event!<br />
		&nbsp;&nbsp; &nbsp; * Refer to https://developers.google.com/youtube/js_api_reference#Events onError<br />
		&nbsp;&nbsp; &nbsp; * @param: e (event)<br />
		&nbsp;&nbsp; &nbsp;**/<br />
		&nbsp; &nbsp;&nbsp;<br />
		&nbsp; &nbsp; function onPlayerError(e) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; dataLayer.push({<br />
		<span style="color:#0000FF;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event: &#39;error&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventCategory: &#39;youtube&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventAction: &#39;play&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventLabel: &#39;youtube: &#39; + e</span><br />
		&nbsp; &nbsp; &nbsp; &nbsp; })<br />
		&nbsp; &nbsp; }
	</p>
<p>
		&nbsp;&nbsp; &nbsp;/**<br />
		&nbsp;&nbsp; &nbsp; * Report the % played if it matches 0%, 25%, 50%, 75%, 90% or completed<br />
		&nbsp;&nbsp; &nbsp; * @param: e (event)<br />
		&nbsp;&nbsp; &nbsp;**/<br />
		&nbsp; &nbsp; function onPlayerPercent(e) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; if (e[&#8220;getPlayerState&#8221;]() == YT.PlayerState.PLAYING) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //var t = e[&#8220;getDuration&#8221;]() &#8211; e[&#8220;getCurrentTime&#8221;]() <= 1.5 ? 1 : (Math.floor(e["getCurrentTime"]() / e["getDuration"]() * 4) / 4).toFixed(2);<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Set the played duration to every tenth because we&#39;ll need to also capture 90% played.<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var t = e[&#8220;getDuration&#8221;]() &#8211; e[&#8220;getCurrentTime&#8221;]() <= 1.5 ? 1 : (Math.floor(e["getCurrentTime"]() / e["getDuration"]() * 10) / 10).toFixed(2);<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (parseFloat(t) &lt; 0.25) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = 0.00;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (parseFloat(t) &lt; 0.5){<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = 0.25;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (parseFloat(t) &lt; 0.75){<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = 0.50;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (parseFloat(t) &lt; 0.9){<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = 0.75;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (parseFloat(t) &lt; 1){<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = 0.90;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // duration t needs to be fixed to 2 decimal places<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = t.toFixed(2);<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!e[&#8220;lastP&#8221;] || t > e[&#8220;lastP&#8221;]) {<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var video_data = e[&#8220;getVideoData&#8221;](),<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label = video_data.video_id + &#39;:&#39; + video_data.title;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e[&#8220;lastP&#8221;] = t;<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataLayer.push({<br />
		<span style="color:#0000FF;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event: &quot;youtube&quot;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventCategory: &#39;youtube&#39;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventAction: t * 100 + &quot;%&quot;,<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventLabel: label</span><br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e[&#8220;lastP&#8221;] != 1 &amp;&amp; setTimeout(onPlayerPercent, 1000, e);<br />
		&nbsp; &nbsp; &nbsp; &nbsp; }<br />
		&nbsp; &nbsp; }<br />
		&nbsp;&nbsp; &nbsp;<br />
		&nbsp;&nbsp; &nbsp;/**<br />
		&nbsp;&nbsp; &nbsp; * Add unload event listener<br />
		&nbsp;&nbsp; &nbsp;**/<br />
		&nbsp;&nbsp; &nbsp;window.addEventListener(&#39;beforeunload&#39;, function(e){<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (var i = 0; i &lt; gtmYTPlayers.length; i++){<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (gtmYTPlayers[i].getPlayerState() === 1) { // playing<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var video_data = gtmYTPlayers[i][&#8216;getVideoData&#8217;](),<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;label = video_data.video_id + &#39;:&#39; + video_data.title;<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;dataLayer.push({<br />
		<span style="color:#0000FF;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;event: &#39;youtube&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventCategory: &#39;youtube&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventAction: &#39;exit&#39;,<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eventLabel: label</span><br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;});<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
		&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
		&nbsp;&nbsp; &nbsp;})<br />
		&nbsp; &nbsp;&nbsp;<br />
		&nbsp;&nbsp; &nbsp;// load the Youtube JS api and get going<br />
		&nbsp; &nbsp; var j = document.createElement(&quot;script&quot;),<br />
		&nbsp; &nbsp; &nbsp; &nbsp; f = document.getElementsByTagName(&quot;script&quot;)[0];<br />
		&nbsp; &nbsp; j.src = &quot;//www.youtube.com/iframe_api&quot;;<br />
		&nbsp; &nbsp; j.async = true;<br />
		&nbsp; &nbsp; f.parentNode.insertBefore(j, f);<br />
		&lt;/script&gt;
	</p>
</blockquote>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-9.png" style="width: 550px; height: 351px;" />
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-11.png" style="width: 550px; height: 86px;" />
</p>
<p>
	&nbsp;
</p>
<h1>
	GA呈現結果<br />
</h1>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/81-gtm-12.png" style="width: 550px; height: 255px;" />
</p>
<p>
	使用次要維度，就可以區分不同的頁面。<br />
	但若同一個頁面有好多個影片，就要另外處理了～
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm0814-1.png" style="width: 550px; height: 289px;" />
</p>
<p>
	次要維度選擇裝置類別，也可以觀看桌機或手機的數據。
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm0814-2.png" style="width: 550px; height: 248px;" /></p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7134/gtm-youtube/">GTM – 監控 Youtube 影片點擊</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/7134/gtm-youtube/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Google Tag Manager &#8211; Trigger</title>
		<link>https://blog.cindygirl.cc/archives/7097/google-tag-manager-trigger/</link>
					<comments>https://blog.cindygirl.cc/archives/7097/google-tag-manager-trigger/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Fri, 28 Jul 2017 09:12:40 +0000</pubDate>
				<category><![CDATA[GTM]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=7097</guid>

					<description><![CDATA[<p>這一篇記錄 Google Tag Manager &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7097/google-tag-manager-trigger/">Google Tag Manager &#8211; Trigger</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>
	這一篇記錄 Google Tag Manager Trigger 的設定<br />
	或許方法不漂亮，但是一樣可以達到追蹤目的。<br />
	反正就是學習記錄～<br />
	&nbsp;
</p>
<h2>
	頁面說明<br />
</h2>
<p>
	頁面網址 &nbsp;http://xxx.com/active/20170728<br />
	頁面上只有一顆按鈕，按鈕名稱叫「想了解更多」
</p>
<h2>
	Trigger<br />
</h2>
<p>
	1. 點擊頁面上的文字 包含&nbsp;想了解更多<br />
	2. 頁面網址 包含 active/20170728<br />
	&nbsp; &nbsp; 我會多設定一項 Page Url<br />
	&nbsp; &nbsp; 避免其他頁面也有「想了解更多」, 這樣數據就會不準確。
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm1.png" style="width: 650px; height: 281px;" />
</p>
<hr />
<h2>
	&nbsp;<br />
</h2>
<h2>
	頁面說明<br />
</h2>
<p>
	頁面網址 &nbsp;http://xxx.com/active/20170729<br />
	頁面上有好多顆按鈕，按鈕名稱都叫「想了解更多」
</p>
<p>
	想要追蹤哪一顆按鈕，被點擊的次數比較多<br />
	為了區分每顆按鈕，給予每一顆按鈕不同的class名稱<br />
	例如 btn1、btn2&#8230;等
</p>
<h2>
	Trigger<br />
</h2>
<p>
	這裡選擇 Click Element, 而不是 Click Classes,<br />
	因為&nbsp;Click Classes 我試了很多次都抓不到呀!!!&nbsp; <span style="color:#FF0000;">(後來設定成功了，下方有更新)</span><br />
	如果之後有研究出來，再來修正。
</p>
<p>
	第一顆按鈕
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm-trigger-1.png" style="width: 600px; height: 269px;" />
</p>
<p>
	第二顆按鈕
</p>
<p>
	<img decoding="async" alt="" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/gtm-trigger-2.png" style="width: 600px; height: 271px;" />
</p>
<p>
	這種作法有點麻煩就是了，如果有10顆按鈕，就要製作10次。<br />
	可以寫成JS, 但還沒實際操作，研究完之後再補上。<br />
	&nbsp;
</p>
<h2>
	Trigger Class Name<br />
</h2>
<p>
	之前設定 Click Classes 一直不成功，終於發現原因了！<br />
	眉角就是，若有多組Class Name , 一定要包含第一個 Class Name，否則會判斷不到～
</p>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/trigger_class_name.png" style="width: 800px; height: 42px;" />
</p>
<p>
	如果只設定&nbsp;glyphicon-heart，Trigger 會沒有反應喔～
</p>
<p>
	<img decoding="async" class="alignnone size-large" src="https://img.cindygirl.cc/gtm/trigger_class_setting.png" style="width: 700px; height: 339px;" /></p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7097/google-tag-manager-trigger/">Google Tag Manager &#8211; Trigger</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/7097/google-tag-manager-trigger/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Google Tag Manager &#8211; Google 代碼管理工具</title>
		<link>https://blog.cindygirl.cc/archives/7094/google-tag-manager-1/</link>
					<comments>https://blog.cindygirl.cc/archives/7094/google-tag-manager-1/#respond</comments>
		
		<dc:creator><![CDATA[cindygirl]]></dc:creator>
		<pubDate>Fri, 28 Jul 2017 09:09:32 +0000</pubDate>
				<category><![CDATA[GTM]]></category>
		<category><![CDATA[學習筆記]]></category>
		<guid isPermaLink="false">https://blog.cindygirl.cc/?p=7094</guid>

					<description><![CDATA[<p>最近一直在碰 GTM (Google Tag Ma&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7094/google-tag-manager-1/">Google Tag Manager &#8211; Google 代碼管理工具</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>
	最近一直在碰 GTM (Google Tag Manager), 所以就來記錄一下好了。
</p>
<h2>
	古老時代<br />
</h2>
<p>
	以前公司要埋一堆追蹤代碼 GA 、FB&#8230;等等<br />
	工程師總是要找到對應功能的程式位置<br />
	追蹤代碼散落一地!!! 程式碼看起來也超亂的。
</p>
<h2>
	GTM出現<br />
</h2>
<p>
	出現GTM這個工具，它統一管理所有的追蹤代碼, 真的是好物呀～<br />
	這個工具對於工程師來說，比較好上手。<br />
	沒有工程背景的人，是需要一點時間學習，它不難學習，但需要一點邏輯。
</p>
<h2>
	用了GTM<br />
</h2>
<p>
	改用GTM之後，網站只需要置入一段GTM追蹤碼，程式碼整個乾淨很多！<br />
	如果用wordpress, 只要安裝GTM外掛, 把GTM代碼填上去, 更方便！
</p>
<p>
	如何開始跟安裝GTM，我就懶得寫了，因為動手 google 就一堆相關文章了。</p>
<p>這篇文章 <a rel="nofollow" href="https://blog.cindygirl.cc/archives/7094/google-tag-manager-1/">Google Tag Manager &#8211; Google 代碼管理工具</a> 最早出現於 <a rel="nofollow" href="https://blog.cindygirl.cc">任姓人妻 の 生活紀錄</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.cindygirl.cc/archives/7094/google-tag-manager-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
