Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active December 11, 2015 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/4553066 to your computer and use it in GitHub Desktop.
Save pingyen/4553066 to your computer and use it in GitHub Desktop.
Google Analytics + Custom Search
<script src="http://www.google-analytics.com/ga.js" ></script>
<script>
try {
var pageTracker = _gat._getTracker('UA-6851063-1');
pageTracker._trackPageview();
} catch(e) {}
</script>
<form action="http://www.google.com.tw/cse" target="_blank" style="margin : 10px 0" >
<input type="hidden" name="cx" value="partner-pub-1821434700708607:3830778188" >
<input type="hidden" name="ie" value="UTF-8" >
<input type="text" name="q" style="width : 135px" >
<input type="submit" name="sa" value="搜尋" >
</form>
<script>
var google_ad_client = 'ca-pub-1821434700708607',
google_ad_slot,
google_ad_slot2,
google_ad_width,
google_ad_height;
(function() {
var $contentAll = $('#content_all');
if($contentAll[0]) {
if($contentAll.height() < 500) {
google_ad_slot = '8707544963';
google_ad_slot2 = '7396761193';
}
else {
google_ad_slot = '1136574796';
google_ad_slot2 = '2613307994';
}
google_ad_width = 468;
google_ad_height = 60;
}
else {
google_ad_slot = '2826960791';
google_ad_width = 728;
google_ad_height = 90;
}
var w = document.write;
document.write = function(str) {
if(str.substr(0, 5) === '<ins ') {
if(google_ad_slot2)
$contentAll.before(str);
else
$('#banner').append(str);
}
document.write = w;
}
})();
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" ></script>
<script>
if(google_ad_slot2) {
google_ad_client = 'ca-pub-1821434700708607';
google_ad_slot = google_ad_slot2;
google_ad_width = 468;
google_ad_height = 60;
delete google_ad_slot2;
(function() {
var w = document.write;
document.write = function(str) {
if(str.substr(0, 5) === '<ins ')
$('#content_all').css('paddingBottom', '6px').after(str);
document.write = w;
}
w.call(document, '<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" ></sc' + 'ript>');
})();
}
</script>
<script>
google_ad_client = 'ca-pub-1821434700708607';
google_ad_slot = '8156194155';
google_ad_width = 200;
google_ad_height = 200;
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" ></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment