Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Addon] AdWords Dynamic Remarketing Tag


fur

Recommended Posts

This a light-weight add-on for Google AdWords dynamic remarketing tag.

 

Dynamic remarketing lets you reach your past site visitors with ads that show the specific products people viewed on your site. Once you've set up your dynamic remarketing campaign, you'll need to add the dynamic remarketing tag, including custom parameters, to your site so your lists can start working.

 

More on: https://support.google.com/adwords/answer/3103357?hl=en

 

Download here

 

 

Edited by burt
removed external url

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

hi Richard, thank you for your contribution.

I've just a little problem: I've installed SPPC on my web page and when I made a special offer the tag doesn't charge the special price but only the original price.

 

I think that it should be very important for the remarketing campaign that the special would be shown.

 

do you have any idea?

thank you again for your help.

riccardo

Link to comment
Share on other sites

Hi Richard,

I thought I've solved the problem doing this change in FILENAME_PRODUCT_INFO, but it seems doesn't work correctly.

 

case FILENAME_PRODUCT_INFO:

global $_GET;

if(tep_not_null($_GET['products_id'])){

$return[0] = "'" . $_GET['products_id'] . "'";

global $product_info;

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

$product_info['specials_new_products_price'] = $new_price;

}

$return[2] = $product_info['specials_new_products_price'] ? $product_info['specials_new_products_price'] : $product_info['products_price'];

}

$return[1] = 'product';

break;

 

do you other ideas... ? I'm not a professional coder.... :-

 

thank you

riccardo

Edited by rikic
Link to comment
Share on other sites

Thanks for pointing this out riccardo,

 

My apologize I customized products_info.php page and put $product_info['specials_new_products_price'] by my own.

 

Your approach is correct and I cannot see anything wrong in your code...

 

My site doesnt have SPPC installed so I can't test it esaily... My updated version work good in special price with function tep_get_products_special_price()...

 

So... may be if you can locate and post the part of code where the special price is shown in product_info.php, that may help debugging...

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

  • 2 weeks later...

Hi richard,

I've tested last version of yo our contribution on my website abnd I think there's a bug: it doesn't charge the "coma" in the price.

I mean, if the price is € 109,00 it shows 10900.

any idea?

thank you very much

riccardo

Link to comment
Share on other sites

thx for your reply, rikic

 

I did that on purpose, in US dollars e.g. $1,234.56 need to be 1234.56...

had no idea comma in € can be decimal point too... may work on it these few days...

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

  • 1 month later...

AdWords Dynamic Remarketing Tag 1.5 uploaded. Featured admin configuration and easier to install/unstall.

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

sorry missed a function in admin general.php, please download the new version and add the function only.

 

also tested working in 2.3.x in new version

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

  • 3 months later...

@@burt

 

I couldn't edit my own thread after a curtain time.... I can only quote the thread.... Think that's the rule for normal member?

Edited by fur

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

 

I have installed this and have it working ok as far as I can see from the Tag Assistant but my product values are all 0.00 as you can see

 

 										<script type="text/javascript">											 							var google_tag_params = {											 							ecomm_prodid: '4102',											 							ecomm_pagetype: 'product',											 							ecomm_totalvalue: '0.00'											 							};											 							</script>			

 

My site is http://www.coastwatersports.com/ you can check any product they are all 0.00

 

Any idea whats up?

 

Thanks

 

Dave

Edited by stubbsy
Link to comment
Share on other sites

  • 3 months later...

Hi stubbsy,

 

sorry for the very late reply. It seems work ok in your product page. Have you fixed it?

AdWords Dynamic Remarketing Tag - Tell Google What to Advertise [2.2.x] [2.3.x]

AjaxCheckoutAddress - Change Address and Checkout in Once [2.2.x]

SmartSuggest - Self-learning Ajax Search Suggestion [2.2.x] [2.3.x]

 

More about me.

Link to comment
Share on other sites

  • 2 years later...
echo 'ecomm_totalvalue: \'' . $this->page_totalvalue . '\'' . "\n";

This line is giving me issues...

First the current Google spec call for a numeric entry with no quotes.

 

I tried changing to

echo 'ecomm_totalvalue: ' . $this->page_totalvalue . '' . "\n";

which works on product pages that have a price, but gives an error on all other pages that do not have a product (null entries), with error "Tag Paramater object could not be parsed."

 

So the original line works ok on non product pages but not well on product pages.

The revised line works ok on product pages, but not on other pages

 

What do do? Any help appreciated.  The code is brief, so here is the whole file: adwords_tag.php (remarketing tag)

 

class adwords_tag {
	
	/**
	 * $page_totalvalue is the current page type
	 * @var object
	 */
	var $page_type;
	
	/**
	 * $page_totalvalue is the current page products ids
	 * @var object
	 */
	var $page_products_id;

	/**
	 * $page_totalvalue is the current page products total value
	 * @var object
	 */
	var $page_totalvalue;
	
	/**
	 * $installer is the installer object
	 * @var object
	 */
	var $installer;
	
	function adwords_tag() {
		$this->installer = new adwords_tag_install;
	
		$scriptname = ltrim(basename($_SERVER['SCRIPT_NAME']));
		$return = array();
		switch($scriptname){
			case FILENAME_DEFAULT:
				global $category_depth;
				if($category_depth == 'top')
					$this->page_type = 'home';
				else
					$this->page_type = 'category';
				$this->page_products_id = "''";
				break;
			case FILENAME_PRODUCT_INFO:
				global $_GET, $currency, $currencies;
				if(tep_not_null($_GET['products_id'])){
					$this->page_products_id = "'" . $_GET['products_id'] . "'";
					global $product_info;
					$rate = $currencies->currencies[$currency]['value'];
					$decimal_places = $currencies->currencies[$currency]['decimal_places'];
					$this->page_totalvalue = number_format(tep_add_tax($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) * $rate, $decimal_places);
					if($new_price = tep_get_products_special_price($product_info['products_id']))
						$this->page_totalvalue = number_format(tep_add_tax($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])), $decimal_places);
				}else{
					$this->page_products_id = "''";
				}
				$this->page_type = 'product';
				break;
			case FILENAME_SHOPPING_CART:
				global $cart, $currency, $currencies;
				if($cart && is_object($cart)){
					$products_id_list = array();
					foreach($cart->contents as $products_id => $products_content)
						$products_id_list[] = "'" . (int)$products_id . "'";
					if(count($products_id_list) <= 0)
						$this->page_products_id = "''";
					elseif(count($products_id_list) == 1)
						$this->page_products_id = $products_id_list[0];
					else
						$this->page_products_id = '[' . implode(',', $products_id_list) . ']';
					$rate = $currencies->currencies[$currency]['value'];
					$decimal_places = $currencies->currencies[$currency]['decimal_places'];
					$this->page_totalvalue = number_format($cart->show_total() * $rate, $decimal_places);
				}else{
					$this->page_products_id = "''";
				}
				$this->page_type = 'cart';
				break;
			case FILENAME_CHECKOUT_SHIPPING:
			case FILENAME_CHECKOUT_PAYMENT:
			case FILENAME_CHECKOUT_CONFIRMATION:
			case FILENAME_CHECKOUT_SUCCESS:
				global $order, $currency, $currencies;
				if($order && is_object($order)){
					$products_id_list = array();
					foreach($order->products as $product)
						$products_id_list[] = "'" . (int)$product['id'] . "'";
					if(count($products_id_list) <= 0)
						$this->page_products_id = "''";
					elseif(count($products_id_list) == 1)
						$this->page_products_id = $products_id_list[0];
					else
						$this->page_products_id = '[' . implode(',', $products_id_list) . ']';
					$rate = $currencies->currencies[$currency]['value'];
					$decimal_places = $currencies->currencies[$currency]['decimal_places'];
					if($scriptname == FILENAME_CHECKOUT_SHIPPING || $scriptname == FILENAME_CHECKOUT_PAYMENT){ // calculate the shipping tax
						if($scriptname == FILENAME_CHECKOUT_PAYMENT){
							require(DIR_WS_CLASSES . 'shipping.php');
							$shipping_modules = new shipping;
						}
						$module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
						$shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
						$order->info['total'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
					}
					$this->page_totalvalue = number_format($order->info['total'] * $rate, $decimal_places);
				}else{
					$this->page_products_id = "''";
				}
				$this->page_type = 'purchase';
				break;
			case FILENAME_ADVANCED_SEARCH_RESULT:
				$this->page_products_id = "''";
				$this->page_type = 'searchresults';
				break;
			default:
				$this->page_products_id = "''";
				$this->page_type = 'other';
		}	
	}
	
	function output() {
		echo '<script type="text/javascript">' . "\n";
		echo 'var google_tag_params = {' . "\n";
		echo 'ecomm_prodid: ' . $this->page_products_id . ',' . "\n";
		echo 'ecomm_pagetype: \'' . $this->page_type . '\',' . "\n";
//		echo 'ecomm_totalvalue: \'' . $this->page_totalvalue . '\'' . "\n";
		echo 'ecomm_totalvalue: ' . $this->page_totalvalue . '' . "\n";
		echo '};' . "\n";
		echo '</script>' . "\n";
		
		echo '<script type="text/javascript">' . "\n";
		echo '/* <![CDATA[ */' . "\n";
		echo 'var google_conversion_id = ' . ADWORDS_TAG_GOOGLE_CONVERSION_ID . ';' . "\n";
		if (tep_not_null(ADWORDS_TAG_GOOGLE_CONVERSION_LABEL))
			echo 'var google_conversion_label = "' . ADWORDS_TAG_GOOGLE_CONVERSION_LABEL . '";' . "\n";
		echo 'var google_custom_params = window.google_tag_params;' . "\n";
		echo 'var google_remarketing_only = true;' . "\n";
		echo '/* ]]> */' . "\n";
		echo '</script>' . "\n";

		echo '<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">' . "\n";
		echo '</script>' . "\n";

		echo '<noscript>' . "\n";
		echo '<div style="display:inline;">' . "\n";
		echo '<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/' . ADWORDS_TAG_GOOGLE_CONVERSION_ID . '/?value=0&' . (tep_not_null(ADWORDS_TAG_GOOGLE_CONVERSION_LABEL) ? 'label=' . ADWORDS_TAG_GOOGLE_CONVERSION_LABEL . '&' : '') . 'guid=ON&script=0"/>' . "\n";
		echo '</div>' . "\n";
		echo '</noscript>' . "\n";
	}
}

 

-Dave

Link to comment
Share on other sites

easiest I think is to initialize the value to 0 in the 'var' declaration in the beginning of the file.

 

	var $page_totalvalue = 0;
it is kinda dirty, possibly you should not have that line when you have null values, but forcing it to be 0 will likely get rid of the error for you.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

@@Roaddoctor You can just test the value and change the output to suit:

  if( empty( $this->page_totalvalue ) {
    echo 'ecomm_totalvalue: \'\'' . "\n"; // No use including the variable if it's empty (null)
  } else {
    echo 'ecomm_totalvalue: ' . $this->page_totalvalue . "\n";
  }

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@kymation

@@bruyndoncx

 

I went with this for now - seems to be OK.  Thank you for the help!

//		echo 'ecomm_totalvalue: \'' . $this->page_totalvalue . '\'' . "\n"; // default
//  Fix 
  if( empty( $this->page_totalvalue ) ) {
	echo 'ecomm_totalvalue: ' . '0' . '' . "\n"; // No use including the variable if it's empty (null)
  } else {
    echo 'ecomm_totalvalue: ' . $this->page_totalvalue . '' . "\n";
  }
//  end fix

-Dave

Link to comment
Share on other sites

@@kymation

@@bruyndoncx

 

I went with this for now - seems to be OK.  Thank you for the help!

//		echo 'ecomm_totalvalue: \'' . $this->page_totalvalue . '\'' . "\n"; // default
//  Fix 
  if( empty( $this->page_totalvalue ) ) {
	echo 'ecomm_totalvalue: ' . '0' . '' . "\n"; // No use including the variable if it's empty (null)
  } else {
    echo 'ecomm_totalvalue: ' . $this->page_totalvalue . '' . "\n";
  }
//  end fix

 

Sorry to say, but my addition of the initialization of the variable to 0 logically does the same and I think is much cleaner code.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Tag inspector giving error

 

correct tag and remove , for thousands seperator

//		echo 'ecomm_totalvalue: \'' . $this->page_totalvalue . '\'' . "\n"; // default
//  Fix 
	echo 'ecomm_totalvalue: ' . '0' . '' . "\n"; // No use including the variable if it's empty (null)
  } else {
		echo 'ecomm_totalvalue: \'' . str_replace(",","",$this->page_totalvalue) . '\'' . "\n";
  }
//  end fix

Getting the Phoenix off the ground

Link to comment
Share on other sites

  • 8 months later...

I've tried the fixes mentioned here and I still can't get rid of the error: Number field should not be quoted: 'ecomm_totalvalue'

When I try either of the fixes the page shows no tags. With the original code it's just the error. 

Anyone still working on this?

Link to comment
Share on other sites

  • 2 years later...

I see Google tag changed

Global tag in header:

<!-- Global site tag (gtag.js) - Google Ads: your tag number -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-your tag number"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-your tag number');
</script>

 

and also to add recommended event snippet:

<script>
  gtag('event', 'page_view', {
    'send_to': 'AW-your tag number',
    'value': 'replace with value',
    'items': [{
      'id': 'replace with value',
      'google_business_vertical': 'retail'
    }]
  });
</script>

 

Anyone done an update on this?

Getting the Phoenix off the ground

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...