Error Embedding Google Ads Tag

  • Posts: 10
  • Thank you received: 0
6 months 1 week ago #360939

I'm trying to embed a google ad script tag in the frontend checkout view 'end' but keep getting "syntax error, unexpected token "<", expecting end of file". I tried placing it after the "defined('_JEXEC') or die('Restricted access');" code block, no luck. Same thing when I place it after "echo JText::_('THANK_YOU_FOR_PURCHASE');" and after the last line of code "$this->nextButton = false;"

It seems like Php is not expecting the js script to be embedded which has me baffled with my limited PHP knowledge. Any ideas

Last edit: 6 months 1 week ago by pqas.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 months 1 week ago #360941

Hi,

When you are in between the <?php and the ?> tags, you are inside PHP code. You can only write PHP code in there.
The last ?> of a file can be omitted (which is usually the case).
Knowing all this, in the checkout / end view file, you want to either add your javascript code before the <?php tag already there, or you want to add a ?> tag at the end, and then add your javascript code.

Note also that we already provide a plugin for Google Analytics, which reports the ecommerce data, including sales to Google:
www.hikashop.com/marketplace/product/108...egration-google.html
You can then configure your Ads account to import the GA purchase events reported by the plugin:
support.google.com/analytics/answer/1063...11877394143257898-EU

The following user(s) said Thank You: pqas

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

  • Posts: 10
  • Thank you received: 0
6 months 1 week ago #360954

Very helpful

Last edit: 6 months 1 week ago by pqas.

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

Time to create page: 0.056 seconds
Powered by Kunena Forum