Last active
August 29, 2015 14:13
-
-
Save ronalfy/37b5974e7ac9d09e0cc4 to your computer and use it in GitHub Desktop.
WooCommerce Google Product Feed Remarketing Footer Code
This file contains hidden or 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
if ( function_exists( 'is_product' ) && is_product() ) : | |
global $post; | |
$product = get_product( $post->ID ); | |
if ( $product->is_in_stock() ) { | |
$price = $product->get_price(); | |
} | |
?> | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '<?php echo esc_js( 'woocommerce_gpf_' . $product->id ); ?>', | |
ecomm_pagetype: 'product', | |
ecomm_totalvalue: <?php echo esc_js( number_format( $price, 2, '.', '') ); ?> | |
}; | |
</script> | |
<?php else: ?> | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '', | |
ecomm_pagetype: 'page', | |
ecomm_totalvalue: '' | |
}; | |
</script> | |
<?Php endif; ?> | |
<script type="text/javascript"> | |
/* <![CDATA[ */ | |
var google_conversion_id = 123456; | |
var google_custom_params = window.google_tag_params; | |
var google_remarketing_only = true; | |
/* ]]> */ | |
</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="//googleads.g.doubleclick.net/pagead/viewthroughconversion/123456/?value=0&guid=ON&script=0"/> | |
</div> | |
</noscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment