我需要用一个链接发生两件事

时间:2015-08-21 07:39:20

标签: html hyperlink google-adwords

我有一个链接,它会打开一个弹出窗口,提供有关如何将此页面添加到书签的说明。现在,我还希望链接能够在点击时触发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( /*@cc_on!@*/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>
&#13;
&#13;
&#13;

&#13;
&#13;
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:

		<!-- Google Code for Add to Cart 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 = 12345678;
		    w.google_conversion_label = "abcDeFGHIJklmN0PQ";
		    w.google_conversion_value = 13.00;
		    w.google_conversion_currency = "USD";
		    w.google_remarketing_only = false;
		  }
		  // DO NOT CHANGE THE CODE BELOW.
		  goog_report_conversion = function(url) {
		    goog_snippet_vars();
		    window.google_conversion_format = "3";
		    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"
		  src="//www.googleadservices.com/pagead/conversion_async.js">
		</script>
	
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.)

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

 

a text link

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

	<!-- Below is a sample image for a file download.
	Replace download_button.gif with your
	button image and the document URL with your file's URL. -->
	<body>
	<img src="download_button.gif" alt="Download Whitepaper"
		width="32" height="32"
		onClick="goog_report_conversion
		('http://www..pdf')"/>
	</body>
	</html>
	
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.
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

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

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