0
votes

I am trying to implement dynamic re-marketing for an eCommerce website. I made all the editions in the code to call dynamic values, but still this code doesn't seem to work. I am getting an error "We haven't detected custom parameters for Retail (Google Analytics)" in AdWords.

This is the code-

<script type="text/javascript">

    var google_tag_params = {
ecomm_prodid: '<?php echo get_the_title();?>',
ecomm_pagetype: '<?php 
if(is_page()){
   echo get_the_title()." page"; 
}else{
session_start();
echo $_SESSION['page_type'];

}
?>',
ecomm_totalvalue: '<?php $product = new WC_Product( get_the_ID() );
session_start();
if($_SESSION['page_type']=="Product details page"){
    echo $price = $product->price;
}
session_unset();
session_destroy();

?>',

dynx_itemid: '<?php echo get_the_title();?>',
dynx_pagetype: <?php 
if(is_page()){
   echo get_the_title()." page"; 
}else{
session_start();
echo $_SESSION['page_type'];

}
?>,
dynx_totalvalue: <?php $product = new WC_Product( get_the_ID() );
session_start();
if($_SESSION['page_type']=="Product details page"){
    echo $price = $product->price;
}
session_unset();
session_destroy();

?>,
};
</script>
1
It would be more useful to see how this looks after the PHP code has been parsed by the server. - Eike Pierstorff
Thanks @EikePierstorff, this is how it looks when this php code is parsed by the server - [ ga('set','dimension1', '10' ); ga('set','dimension2', '' ); ga('set','dimension3', '' ); ]. here dimension1, 2,3 are prodid, pagetype & totalvalue respectively. - Isha

1 Answers

0
votes

It's kinda hard to see what's going on (an example of the HTML output of your PHP script would be helpful), but I noticed that you don't seem to set ecomm_pagetype to one of the allowable values for a retail site, namely one of home, searchresults, category, product, cart, purchase, other.

Also, ecomm_prodid needs to correspond exactly to the product's ID in your Google Merchant feed.