It would be nice if the google_analytics module also included support for tracking Google Adwords Conversions (http://adwords.google.com/support/aw/bin/topic.py?topic=16344)

You can see details about setting it up here:
http://adwords.google.com/support/aw/bin/topic.py?hl=en-uk&topic=16357

Basically, Google gives you the ability to track 'adwords conversions' That is, a user who came to your site through an AdWord click, and navigated to one of your 'convernsion pages' - probably a thankyou page just after a purchase, or sign up (depending on what kind of conversions you want to track). In the Google AdWords admin pages, you can set up several 'actions' (an action being 'sign up for x', 'purchase of y' etc). For each action you set up, they provide you with a unique code snipet to place on the conversion page for that action. As far as I can tell, there are only one things that changes from snippet to snippet - they call it a 'google_conversion_label' As well as this, you must have your own 'google_conversion_id'

An example of a code snippet they provide:

<!-- Google Code for Single Donation IE/INT Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1069116697;
var google_conversion_language = "en_GB";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "QiYYCPWPkAEQmdrl_QM";
//-->
</script>
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height="1" width="1" border="0" src="https://www.googleadservices.com/pagead/conversion/1069116697/?label=QiYYCPWPkAEQmdrl_QM&amp;guid=ON&amp;script=0"/>
</noscript>

For reference, the code I put together to insert the correct code for my conversion pages is as follows... , It's horrible as hell as there is hard coded values and no admin interface, but I just needed to get the code on the pages ASAP! :P

function mymodule_footer() {

  $path = drupal_get_path_alias($_GET['q']);

  // Each 'action' has a unique 'label'
  if ($path == 'some/action/thankyou') {
    $label = 'bK93CLeTkAEQmdrl_QM';
  }
  elseif ($path == 'some/other/action/done') {
    $label = '9f-dCM-QkAEQmdrl_QM';
  }

  $id = 1234567845;  // I think this is unique to your adwords account
  $language = 'en_GB';
  $format = '3';
  $color = 'ffffff';

  // Build tracker code for footer.
  $script .= 'var google_conversion_id = '. drupal_to_js($id) .';';
  $script .= 'var google_conversion_language = '. drupal_to_js($language) .';';
  $script .= 'var google_conversion_format = '. drupal_to_js($format) .';';
  $script .= 'var google_conversion_color = '. drupal_to_js($color) .';';
  $script .= 'var google_conversion_label = '. drupal_to_js($label) .';';
  drupal_add_js($script, 'inline', 'footer');
  
  // Insert a link to the external javascript
  $external_js = 'https://www.googleadservices.com/pagead/conversion.js';
  drupal_add_js('document.write(unescape("%3Cscript src=\''. $external_js . '\' type=\'text/javascript\'%3E%3C/script%3E"));', 'inline', 'footer');
}

What do you think about adding support for this into the google_analytics module? The admin interface would need:

1) a way to provide your adwords google_conversion_id
1) a way to define 'actions' - to mirror those you create in your adwords account (name, description, google_conversion_label)
2) a way to associate one or more conversion pages with each action (probably a textarea just like the pages exclude/include for the analytics code)

Comments

hass’s picture

Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

I viewed the integration video and so on, but it sounds like a complex task to make this user friendly and maybe out of scope of the main GA module. It may be easier for you to create a CCK textarea that allows marketing to paste the google code as is into. It was a bit stressful in past to teach/explain many newbies that they do not need to add the standard GA code into the GA custom JS textarea... at some days I turned on basic code validation and from these day these issues have been stopped. I'd like to keep the main GA module nearly support free...

I'm not using this ugly ads myself and I need a code proposal for integration with very easy to configure UI elements. It may be better to create a new (sub-)module for this like the ubercart ga module. We should also do not forget to work on #231451: Add hook to alter data before sending it to browser.

mrfelton’s picture

Status: Postponed (maintainer needs more info) » Active

In the boilerplate code above, the only thing that changes from page to page is the line:

var google_conversion_label = "QiYYCPWPkAEQmdrl_QM";

So, the admin interface for this basically needs to allow you to associate a google_conversion_label with a path (or multiple paths). Associating things with specific paths has been done a thousand times already, so there is nothing ground-breaking here in terms of admin interface.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

So we need a cck field for google_conversion_label in every node? It may be the easiest way to implement prefilled cck fields for all this values and leave the google_conversion_label not prefilled. Maybe someone like to use different codes between specific node types... Can you write the code and test it?

Leaving needs info for discussion of the best solution

mrfelton’s picture

Status: Postponed (maintainer needs more info) » Active

I really don't think this should be implemented with a cck field, but instead a custom module should provide a field into the node edit form allowing users specify a google_conversion_label to use on that that node. If a value is specified for google_conversion_label, the module should inject the relevant javascript into the page - ideally using an implementation of the proposed hook in #231451: Add hook to alter data before sending it to browser.

So essentially I am proposing to write a separate module that depends on google_analytics, and uses it's hook to add the additional tracking code and script. That is, assuming the hook in that other ticket becomes a reality (I think that the hook is by far the best suggestion in that other thread to allow modules such as the one I am proposing to add new tracking capabilities - http://drupal.org/node/231451#comment-900139)

hass’s picture

Yes, could be a submodule of GA or an extra module.

summit’s picture

Hi,
Subscribing, needing tracking of adsense also, because of made combination between analytics and adwords.
It says, I have to fill this above in the code:

<script type="text/javascript">
window.google_analytics_uacct = "UA-code";
</script>

Is this what this thread is about?

Greetings, Martijn

hass’s picture

No, this already works by enabling the adwords checkbox

summit’s picture

Thanks Alexander! I saw it in latest .dev. Greetings, Martijn

hass’s picture

Status: Active » Closed (won't fix)

6 months without moving anything forward. Closing inactive feature request.

rickmanelius’s picture

I agree that this shouldn't be a CCK field.

For me, it would be best if this looked like the global redirects module's menu.
build/path-redirect

The reason being is that it doesn't matter on a per node basis, but could be URL specific. For instance, they just got through the ubercart checkout process and they are not at that particular URL.

So the form would be somethng like
URL:store/completed
Tracking code: adfjasdfdsafkdfs

And then we'd be able to add/delete these entries.

I don't know if this necessarily fits into this module at all or as a submodule. I found this during a google search and it's a big problem for my company as I don't have the time to add this entire block of code every time we want to track this or that adwords conversion. I'm about a level 6 out of 10 in terms of drupal module building, so I don't know if I could take this all on myself. But I certainly would know how to spec and debug, etc if anyone else is willing to help out.

rickmanelius’s picture

For now, it's probably best to use a preprocess function, and if it's on the correct url, insert tracking code via drupal_add_js and then put an area in page.tpl.php to handle the 'no script' portion.

edit:*
This advice is simply a copy of that by the original poster... so yeah, a decent option for now.

jasonsavino’s picture

Not sure if this is the correct place to put this but I just contributed a simple module that I made for a site I am working on, Google AdWords.

hass’s picture