Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cdata_markupfix($content) {
- $content = str_replace("]]>", "]]>", $content);
- return $content;
- }
- function cdata_template_redirect($content) {
- ob_start('cdata_markupfix');
- }
- add_action('template_redirect', 'cdata_template_redirect', -1);
- function my_custom_tracking( $order_id ) {
- $order = wc_get_order( $order_id );
- $totalValue = $order->get_total();
- $currency = $order->currency;
- ?>
- <!-- Google Code for Purchase Conversion Page -->
- <script type="text/javascript">
- /* <![CDATA[ */
- var google_conversion_id = 1234567890;
- var google_conversion_language = "en";
- var google_conversion_format = "1";
- var google_conversion_color = "666666";
- var google_conversion_label = "xxxxXXx1xXXX123X1xX";
- if (<?php echo $totalValue ?>) {
- var google_conversion_value = <?php echo $totalValue ?>;
- var google_conversion_currency = <?php echo $currency ?>;
- }
- var google_remarketing_only = false;
- /* ]]> */
- </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/1234567890/?value=
- <?php echo $totalValue ?>&currency_code=<?php echo $currency ?>
- &label=xxxxXXx1xXXX123X1xX&guid=ON&script=0">
- </div>
- </noscript>
- <?php
- }
- add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement