VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: Scincus on August 18, 2016, 21:10:24 PM

Title: Retargeting javascript code
Post by: Scincus on August 18, 2016, 21:10:24 PM
I am trying to set up a retargeting campaign at the Dutch adcrowd.com. I use a google shopper xml for the product-feed. Adcrowd works with a javascript 'smartpixel'. I put this code in the footer sector (it works) The smartpixel is as follows:

<script type="text/javascript">
var _ac = {};
// _ac.value = '19.99'; // Optioneel: voeg waarde toe aan conversies.
// _ac.order_id = 'ABC123'; // Voeg je eigen order-id toe voor rapportage (optioneel)
_ac.product = '123456'; // Webmaster: vervang op de productpagina 123456 door het product id.

(function(d, t) {
  var a = d.createElement(t), s = d.getElementsByTagName(t)[0];
  a.async = a.src = '//pixel.adcrowd.com/smartpixel/03b264c595403666634ac75d828439bc.js';
  s.parentNode.insertBefore(a, s);
}(document, 'script'));
</script>

My problem is the -ac.product code. What do I place here for an overall dynamic code

Thnx, Henk
Title: Re: Retargeting javascript code
Post by: GJC Web Design on August 18, 2016, 21:55:41 PM
you put what ever is easiest for u to identify the product I assume.. perhaps sku or the product id

if not in VM then try

<?php
$jinput = JFactory::getApplication()->input;
$pid = $jinput->get('virtuemart_product_id');
?>

~~~~~~~~~~~~~


_ac.product = '<?php echo $pid; ?>';

but would be simpler in the VM product details template so you have any var u need
Title: Re: Retargeting javascript code
Post by: Scincus on August 20, 2016, 17:14:02 PM
Thnx! I tried the simple code. But it did not work :(. I did not try the first code yet. I don't know where to place it.
Title: Re: Retargeting javascript code
Post by: GJC Web Design on August 20, 2016, 17:49:15 PM
simple code?

add YOUR code to the product details template .. that's where it should be.. then all the vars are there

_ac.product = '<?php echo $this->product->product_sku; ?>';
Title: Re: Retargeting javascript code
Post by: Scincus on August 20, 2016, 19:37:03 PM
With the simpel code I meant adding: _ac.product = '<?php echo $pid; ?>'; to the footer of all pages in my template. Is this the page that I have to change: public_html/components/com_virtuemart/views/productdetails/tmpl/default.php? Where do I place it, and what precisely. Sorry, I am not very good at modifying php files.
Title: Re: Retargeting javascript code
Post by: Scincus on August 29, 2016, 20:45:11 PM
Is there somebody who can help me?
Title: Re: Retargeting javascript code
Post by: GJC Web Design on August 29, 2016, 22:06:44 PM
you over ride the file you mention.. yes

then

Quoteadd YOUR code to the product details template - anywhere .. that's where it should be.. then all the vars are there

_ac.product = '<?php echo $this->product->product_sku; ?>';

so now u just echo out what every var you want to replace in your JS
Title: Re: Retargeting javascript code
Post by: Milbo on August 30, 2016, 16:00:32 PM
and please use the javascript handler of vm http://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html
Title: Re: Retargeting javascript code
Post by: Jumbo! on September 01, 2016, 09:22:10 AM
You can easily add your desired retrageting/tracking codes using VP Conversion Tracking plugin - https://www.virtueplanet.com/extensions/vp-conversion-tracking

Disclaimer: I am the developer of this plugin.
Title: Re: Retargeting javascript code
Post by: Scincus on September 03, 2016, 13:00:34 PM
Thnx for your reaction. If your Plugin solves my problem, I would be really happy and buy it immediately. My problem is that I do not know what to do with the '_ac.productcode'. It seems that there must be a dynamic code. The site is adcrowd.com, the code in my first post. Please confirm that your plugin can do this job!