Google tracking where to enter ID's

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Google tracking where to enter ID's

Postby jeroen@.....nl » Tue May 26, 2020 6:23 pm

My goal is to get Google tracking setup poperly.
I want to track:
- Adwords - Conversions
- Analytics
- tracking from other components like AcyMailing.

I have configured GTM by adding the two pieces of code to my template, seems to work fine for tracking visitors at this point. Next step is to track Adwords conversions.

Questions:
-Next step is to track Adwords conversions, what/where to add this in Joomla/VM/OPC?
-Do I have to add the code (GTM) to my template AND to OPC tracking or just one, and if so which one?

Thanks in advance.
jeroen@.....nl
 
Posts: 12
Joined: Fri Feb 15, 2013 10:08 am

Re: Google tracking where to enter ID's

Postby admin » Mon Jun 01, 2020 11:04 am

hello, which code you added to the template?

wth opc you do not need to alter the templates in matters of the GTM initialization script or in matters of the datalayer.

i suggest to check OPC's implementatoin of GTM this way:
- remove all your GTM plugins and scripts from your templates
- in opc tracking enable GTM
- assign it some order statuses for which the conversion event will be triggered (like confirmed or similar)
- have your agency configure your GTM per the Datalayer and Events provided by OPC (see GTM debug to see all variables that are sent to GTM from OPC)

advanced:
- to properly track only products that are shown to customer (instead of all products loaded at a page request) you may want to alter your category template (or sublayouts/products.php) template to add this:

Code: Select all
$dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('plgUpdateCategoryProducts', array(&$this->products));
$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);


and to support some advanced OPC extensions from within product single template (or any template which uses a product object)
Code: Select all
$dispatcher = JEventDispatcher::getInstance();$dispatcher->trigger('plgUpdateProductObject', array(&$this->product));


and within the products loop or product itself:

Code: Select all
foreach ($this->products as $product) {
      
      $list = 'Category: '.$product->category_name;
      JEventDispatcher::getInstance()->trigger('plgEchoProductOnShow', array(&$product, 2, 'scroll', 'impressions', $list));


at product page itself:
Code: Select all
$list = 'Category: '.$this->product->category_name;
JEventDispatcher::getInstance()->trigger('plgEchoProductOnShow', array(&$this->product, 2, 'productView', 'detail', $list));


best regards, stan
[/code]
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google tracking where to enter ID's

Postby jeroen@.....nl » Sun Jun 07, 2020 2:10 pm

I added:
To <head>
Code: Select all
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-xxxxxxx');</script>
<!-- End Google Tag Manager -->


To <bottom of index.php>
Code: Select all
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-xxxxxxx"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->


If I remove the code from here and add it to OPC, will OPC take care of all tracking? also outside of Virtuemart?
I also added the FaceBook tracking to GTM, will this also stay active when GTM is activated using OPC?

I have done all checking with Google's tooling, all looks fine. I don't work with an agency and I don't have any clue on how to add the necessary variables, events etc to start recording the Adwords conversions properly.
Can you help me with this?
jeroen@.....nl
 
Posts: 12
Joined: Fri Feb 15, 2013 10:08 am

Re: Google tracking where to enter ID's

Postby admin » Fri Jun 19, 2020 2:20 pm

hello, the head is automatically added to all your pages/urls when:
- you enable opc tracking
- when you enable google analytics (or gtm)
- and within the google analytics tab (or gtm) you enable "run on all pages"
---> this inserts either gtm or ga headers

at the same tab you can configure your GTM ID (GTM-xxxxxxx)
best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google tracking where to enter ID's

Postby jeroen@.....nl » Mon Jun 22, 2020 4:11 pm

Thanks, I see some conversions in Adwords now, however the conversions in Analytics still remains a flat line on '0'.
I recall that earlier I could see the sales conversions right down to the ordernumber. Where do I have to look for the setting which handles this? In OPC or should I 'do' something in Analytics?
jeroen@.....nl
 
Posts: 12
Joined: Fri Feb 15, 2013 10:08 am

Re: Google tracking where to enter ID's

Postby loppan » Wed Aug 12, 2020 11:51 pm

admin wrote:advanced:
- to properly track only products that are shown to customer (instead of all products loaded at a page request) you may want to alter your category template (or sublayouts/products.php) template to add this:

Code: Select all
$dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('plgUpdateCategoryProducts', array(&$this->products));
$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);


best regards, stan


Hi Stan! When I add these lines to my sublayouts/producs.php I get an error :

RuposTel.com plg_system_fatal_catcher plugin detected a problem with your site.
Your site caused a blank screen upon a visit of this URL:

https://www.dietrecords.org/shop/apparel/all-apparel

HTTP_REFERER: https://www.dietrecords.org/shop/music/vinyl

Error message data:
1 Using $this when not in object context in file: /sites/www.dietrecords.org/public_html/templates/horme_3_pro/html/com_virtuemart/sublayouts/products.php line: 15



And it's showing a blank page, sort of... works sometimes though, for some categories, but then it stops working a few seconds later.

Any ideas what that could be?

Thanks!

Best

Peter
loppan
 
Posts: 25
Joined: Thu Oct 27, 2016 7:26 am

Re: Google tracking where to enter ID's

Postby admin » Tue Aug 25, 2020 11:06 am

hello, within the sublayouts please locate the foreach loop of products and add the lines below (after the foreach)

Code: Select all
foreach ($products as $area=> &$product)
   {
      
      $dispatcher = JEventDispatcher::getInstance();
      $dispatcher->trigger('plgUpdateProductObject', array(&$product));
      JEventDispatcher::getInstance()->trigger('plgEchoProductOnShow', array(&$product, 2, 'scroll', 'impressions', $list));
      
      
      if (empty($product->product_name)) continue;


and BEFORE the foreach loop you may use it similarly:
Code: Select all
$dispatcher = JEventDispatcher::getInstance();
$dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('plgUpdateCategoryProducts', array(&$products));



in short - some VM templates are using "$this->product" some are using just a $product via a reference in $viewData['product'] and some are using $products.
sublayouts are loaded statically so they always reference object via $viewData ($viewData['products']) and not $this->products

i.e. remove "$this->" from your code.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x

cron