Last active
December 21, 2015 01:38
-
-
Save mglaman/6228979 to your computer and use it in GitHub Desktop.
Creates a checkout pane in Drupal Commerce for Google AdWords tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Checkout Pane AdWords | |
description = AdWords campaign tracking (hard-coded) | |
package = Commerce (contrib) | |
dependencies[] = commerce_checkout | |
core = 7.x | |
; Information added by drupal.org packaging script on 2012-12-09 | |
version = "7.x-1.x-dev" | |
core = "7.x" | |
project = "checkout_pane_adwords" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file checkout_pane_shipping_details.module | |
* Adds a new pane that creates a text message for describing shipping methods | |
*/ | |
/** | |
* Implements hook_commerce_checkout_pane_info(). | |
* | |
* This is where we define the name of the pane, related information, and | |
* the base name of all the form builder functions used to present the | |
* pane. | |
*/ | |
function checkout_pane_adwords_commerce_checkout_pane_info() { | |
$panes['checkout_pane_adwords'] = array( | |
'title' => '', | |
'base' => 'checkout_pane_adwords_pane', | |
// The checkout page where this should be displayed by default. | |
'page' => 'complete', | |
'weight' => 60, | |
); | |
return $panes; | |
} | |
/** | |
* Example Pane: form callback. | |
* | |
* This is a standard FAPI form which will be presented in the pane. | |
* The form gathers and stores information from $order->data, an array which | |
* can be populated with free-form keys and values. | |
*/ | |
function checkout_pane_adwords_pane_checkout_form($form, &$form_state, $checkout_pane, $order) { | |
$message = ' | |
<!-- Google Code for Internet Sale Conversion Page --> | |
<script type="text/javascript"> | |
/* <![CDATA[ */ | |
var google_conversion_id = YOUR_ADWORDS_ID; | |
var google_conversion_language = "en"; | |
var google_conversion_format = "2"; | |
var google_conversion_color = "ffffff"; | |
var google_conversion_label = "YOUR_LABEL"; | |
var google_conversion_value = 0; | |
/* ]]> */ | |
</script> | |
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> | |
</script> | |
<noscript> | |
<div style="display:inline;"> | |
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1041075554/?value=0&label=rObDCJqUmQUQ4pq28AM&guid=ON&script=0"/> | |
</div> | |
</noscript> | |
'; | |
$pane_form['checkout_pane_adwords'] = array( | |
'#markup' => $message | |
); | |
return $pane_form; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Empty pane title is confusing
Otherwise Thanks!