2015-08-21 43 views
1

我有一個鏈接,打開一個彈出窗口,爲您提供如何將此頁面添加到您的書籤的說明。現在,我還希望鏈接在被點擊時在AdWords中觸發轉化。爲此,我有一個來自谷歌的腳本,我嘗試與現有鏈接結合使用,但是我認爲我做了錯誤的事情,因爲在我的測試中沒有轉換被觸發。請幫我在這裏:我需要兩個事情發生與一個鏈接

<html> 
 
<head> 
 
    
 
</head> 
 
<body> 
 
    
 
<a id="bookmarkme" href="#" rel="sidebar" onClick="goog_report_conversion" title="bookmark this page">Bookmark this page!</a> 
 
    
 
    
 
    
 
<!-- Google Code for People who added website to their bookmarks Conversion Page 
 
In your html page, add the snippet and call 
 
goog_report_conversion when someone clicks on the 
 
chosen link or button. --> 
 
<script type="text/javascript"> 
 
    /* <![CDATA[ */ 
 
goog_snippet_vars = function() { 
 
    var w = window; 
 
    w.google_conversion_id = XXXXXXXX; 
 
    w.google_conversion_label = "COldCKSHnl8Q2cu9ywM"; 
 
    w.google_remarketing_only = false; 
 
} 
 
// DO NOT CHANGE THE CODE BELOW. 
 
goog_report_conversion = function(url) { 
 
    goog_snippet_vars(); 
 
    window.google_conversion_format = "3"; 
 
    window.google_is_call = true; 
 
    var opt = new Object(); 
 
    opt.onload_callback = function() { 
 
    if (typeof(url) != 'undefined') { 
 
    window.location = url; 
 
    } 
 
} 
 
var conv_handler = window['google_trackConversion']; 
 
if (typeof(conv_handler) == 'function') { 
 
    conv_handler(opt); 
 
} 
 
} 
 
/* ]]> */ 
 
</script> 
 
    
 
    
 
    
 
    
 
<script type="text/javascript"> 
 
    $(function() { 
 
     $("#bookmarkme").click(function() { 
 
      // Mozilla Firefox Bookmark 
 
      if ('sidebar' in window && 'addPanel' in window.sidebar) { 
 
       window.sidebar.addPanel(location.href,document.title,""); 
 
      } else if(/*@[email protected]*/false) { // IE Favorite 
 
       window.external.AddFavorite(location.href,document.title); 
 
      } else { // webkit - safari/chrome 
 
       alert('Please press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D in order to add this page to your bookmarks, you can also use your browsers bookmark menu to do that.'); 
 
      } 
 
     }); 
 
    }); 
 
</script> 
 
    
 
    
 
</body> 
 
</html>

Setting up an onclick handler for conversions 
 
First, make sure you selected Click instead of Page load from the "Tracking event" section of the "Advanced tag settings" in Part I of the instructions above. Your conversion tag should look like something this: 
 

 
\t \t <!-- Google Code for Add to Cart Conversion Page 
 
\t \t In your html page, add the snippet and call goog_report_conversion 
 
\t \t when someone clicks on the chosen link or button. --> 
 
\t \t <script type="text/javascript"> 
 
\t \t /* <![CDATA[ */ 
 
\t \t goog_snippet_vars = function() { 
 
\t \t  var w = window; 
 
\t \t  w.google_conversion_id = 12345678; 
 
\t \t  w.google_conversion_label = "abcDeFGHIJklmN0PQ"; 
 
\t \t  w.google_conversion_value = 13.00; 
 
\t \t  w.google_conversion_currency = "USD"; 
 
\t \t  w.google_remarketing_only = false; 
 
\t \t } 
 
\t \t // DO NOT CHANGE THE CODE BELOW. 
 
\t \t goog_report_conversion = function(url) { 
 
\t \t  goog_snippet_vars(); 
 
\t \t  window.google_conversion_format = "3"; 
 
\t \t  var opt = new Object(); 
 
\t \t  opt.onload_callback = function() { 
 
\t \t  if (typeof(url) != 'undefined') { 
 
\t \t  window.location = url; 
 
\t \t  } 
 
\t \t } 
 
\t \t var conv_handler = window['google_trackConversion']; 
 
\t \t if (typeof(conv_handler) == 'function') { 
 
\t \t  conv_handler(opt); 
 
\t \t } 
 
\t \t } 
 
\t \t /* ]]> */ 
 
\t \t </script> 
 
\t \t <script type="text/javascript" 
 
\t \t src="//www.googleadservices.com/pagead/conversion_async.js"> 
 
\t \t </script> 
 
\t 
 
Now that you (or the person in charge of your website) have the conversion tracking tag, you're ready to paste. Here's how: 
 

 
Go to the page on your website that shows the clickable button or link. Then open up the HTML code so you can edit it. 
 
Find the body tags (<body></body>) of the page, then paste the code snippet you generated in AdWords between those two tags. 
 
Adjust the HTML code to add the onclick handler. The particular onclick command you use will depend on how the link or button is displayed on your site: text link, image, or button. 
 
Here's some sample code close up: 
 

 
HTML before conversion tracking code (Sample only. Don't use in your website's code.) 
 

 
\t <html> 
 
\t <head> 
 
\t <title>Sample HTML File</title> 
 
\t </head> 
 
\t <body> 
 
\t This is the body of your web page. 
 
\t </body> 
 
\t </html> 
 
\t 
 
Use the following command if the link is shown as: 
 

 
    
 

 
a text link 
 

 
\t <body> 
 
\t <!-- Below is a sample link for a file download. 
 
\t You need to replace the URL for the file and the 
 
\t DOWNLOAD NOW text with the text you want to hyperlink. --> 
 
\t <a onclick="goog_report_conversion 
 
\t \t ('http://www.example.com/whitepapers/a.pdf')" 
 
\t \t href="#" >DOWNLOAD NOW</a> 
 
\t </body> 
 
\t </html> 
 
\t 
 
an image 
 

 
\t <!-- Below is a sample image for a file download. 
 
\t Replace download_button.gif with your 
 
\t button image and the document URL with your file's URL. --> 
 
\t <body> 
 
\t <img src="download_button.gif" alt="Download Whitepaper" 
 
\t \t width="32" height="32" 
 
\t \t onClick="goog_report_conversion 
 
\t \t ('http://www..pdf')"/> 
 
\t </body> 
 
\t </html> 
 
\t 
 
For the tracking to work, you'll need to make sure you include both the tag and the appropriate onclick tags from one of the examples above. This tells AdWords to record a conversion only when a customer clicks on a chosen link or button.

+0

第二段代碼是谷歌adwords的指令。 –

+0

您是否曾嘗試將'google_report_conversion()'添加到您使用jquery設置的onclick方法的開始處?將它從鏈接標記中移除並放入方法中,然後看看會發生什麼! –

回答

0

好吧,它的工作方式如下:

<a onclick="goog_report_conversion 
 
\t \t ('')" id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark this page!</a>

相關問題