Where to add pixel for specific events

  • Posts: 49
  • Thank you received: 6
  • Hikashop Business
3 weeks 3 hours ago #369666

-- HikaShop version -- : 5.1.6
-- Joomla version -- : 5.3.1
-- PHP version -- : 8.2
-- Browser(s) name and version -- : firefox

Hello,

I would like to add a Meta pixel on my website. I have already added the base pixel and would like to know where to add the "view content", "add to cart" and "intiiated checkout" scripts. I am seeing that it needs to be added to the view files in display, but i'm not sure which view file is the correct one for each event. Also, I'm wondering where in the file to add it in order not to mess up with the php code.

Thank you!

Please Log in or Create an account to join the conversation.

  • Posts: 84868
  • Thank you received: 13820
  • MODERATOR
3 weeks 2 minutes ago #369671

Hi,

In case you don't know, please note that there is an extension which already exists for this:
joomlamax.com/joomla-extensions/hikashop...-meta-pixel-tracking
With it, no need to add any code anywhere and it already track the different events you want to track.

For only 29€, I would say it's a no brainer compared to loosing hours fiddling with the different view files and code to integrate it manually on your end.

Now, regarding which view is used where, you can use the "Display view files" setting of the HikaShop configuration:
www.hikashop.com/support/documentation/5...config.html#advanced

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 6
  • Hikashop Business
2 weeks 4 days ago #369698

Hi Nicolas,

Thank you. I've actually recently discovered this extension which looks pretty good, the only problem being that it requires me to use a token from Meta and at present I'm not managing to retrieve that token. There must be an issue with my account on that level, and as I'm not getting any answer back from Meta on this, I thought it might be easier and quicker to add the script myself while I resolve this issue as I have an event in a week that i need to promote. So, i'd like to be able to start tracking sign ups for that event.

I have already added the base pixel and the purchase pixel (within an article with url redirect), and i'm now looking to add at the add to cart and initiated checkout events. For the add to cart event, it is when the window pops up with the "proceed to checkout" or "continue shopping", option. I'm not seeing a view file for it when I choose "display the view files". Do you know which view files I'd need to add the script to in order to add this pixel event?

For the checkout initiated, it looks like it's the checkout/show.php view file, but I'm not sure where to put the script in order not to mess up with the code. Meta says to put it in between <head> and </head> and to place it underneath any existing code but above </head>. Do you konw where this would be on this file?

Thank you!

Please Log in or Create an account to join the conversation.

  • Posts: 84868
  • Thank you received: 13820
  • MODERATOR
2 weeks 3 days ago #369703

Hi,

The head area is displayed by the Joomla template.
In the views, you need to use code like this so that the template receives your JS code and adds it to the head:
docs.joomla.org/Adding_JavaScript

The popup after an add to cart is not displayed with a view file. To be able to inject JS code at this point, you need to implement the cart.updated event :
www.hikashop.com/support/documentation/6...ocumentation.html#js
Normally, you would want to place this code with a plugin of the group "system" implementing the onBeforeCompileHead event of Joomla:
docs.joomla.org/Plugin/Events/System#onBeforeCompileHead

Please understand that all this is not easy. It requires properly development. It's not something where you can just copy/paste a few lines of code here and there.

I would rather recommend you check with the support of meta pixel tracking plugin how to get the token you need.

Please Log in or Create an account to join the conversation.

Time to create page: 0.041 seconds
Powered by Kunena Forum