{"id":892,"date":"2018-11-26T13:10:24","date_gmt":"2018-11-26T07:40:24","guid":{"rendered":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/"},"modified":"2023-02-10T10:27:16","modified_gmt":"2023-02-10T04:57:16","slug":"default-template","status":"publish","type":"docs","link":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/","title":{"rendered":"Default Template"},"content":{"rendered":"<p>The ocmod adds the add to cart tracking script to the product page. You will also need to setup manually in case if you want to track the addition of items or removal of items from the product list or grids. This setup is manual because this is the best &amp; effective way to do this without unnecessary loading of more scripts &amp; queries.<\/p>\n<h4><strong>Please follow the below step (<span style=\"color: #ff0000;\">only if you are a developer<\/span>)<\/strong><\/h4>\n<p>The activity involves the identification of the javascript file which is responsible for add to cart \/ remove cart activity. By default, OpenCart uses <strong>catalog\/view\/javascript\/common.js<\/strong> for this activity. In some templates, they might use their own javascript file. You will need to identify that file and make the following changes.<\/p>\n<p>Open<strong>\u00a0catalog\/view\/javascript\/common.js<\/strong><\/p>\n<p><strong>Change 1: Add the following code at the end of the page\/file<\/strong><\/p>\n<pre>function gaAddtocart(e){$.ajax({url:\"index.php?route=extension\/module\/google_ecommerce\/get_product_info&amp;product_id=\"+e,type:\"post\",dataType:\"json\",success:function(e){e.error?console.log(e.error):gtag(\"event\",\"select_content\",{\"content_type\": \"product\",items:[e.product_info]});gtag(\"event\",\"add_to_cart\",{items:[e.product_info]}),console.log(e.product_info),e.pixel_info&amp;&amp;(fbq(\"track\",\"AddToCart\",e.pixel_info),console.log(e.pixel_info))}})}function gaRemovefromcart(e){$.ajax({url:\"index.php?route=extension\/module\/google_ecommerce\/get_product_info&amp;product_id=\"+e,type:\"post\",dataType:\"json\",success:function(e){e.error?console.log(e.error):gtag(\"event\",\"select_content\",{\"content_type\": \"product\",items:[e.product_info]});gtag(\"event\",\"remove_from_cart\",{items:[e.product_info]})}})}<\/pre>\n<p><u><strong><em>Example:<\/em><\/strong><\/u><\/p>\n<p><a href=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-899\" src=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg\" alt=\"\" width=\"1297\" height=\"350\" srcset=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg 1297w, https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-300x81.jpg 300w, https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-768x207.jpg 768w, https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-1024x276.jpg 1024w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p><strong>Change 2: Identify the add to cart function and add the following function just after the success command<\/strong><\/p>\n<pre>gaAddtocart(product_id); \n<\/pre>\n<p><em><u><strong>Example:<\/strong><\/u><\/em><\/p>\n<p><a href=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-addtocart-function.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-addtocart-function.jpg\" alt=\"\" width=\"856\" height=\"525\" \/><\/a><\/p>\n<p><strong>Change 3:\u00a0Identify the remove function and add the following function just after the success command<\/strong><\/p>\n<pre>gaRemovefromcart(json.product_id);<\/pre>\n<p><a href=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-removecart.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-898\" src=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-removecart.jpg\" alt=\"\" width=\"1003\" height=\"538\" srcset=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-removecart.jpg 1003w, https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-removecart-300x161.jpg 300w, https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default-removecart-768x412.jpg 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/a><\/p>\n","protected":false},"featured_media":0,"parent":870,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-892","docs","type-docs","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Default Template - HuntBee Resources<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Default Template - HuntBee Resources\" \/>\n<meta property=\"og:description\" content=\"The ocmod adds the add to cart tracking script to the product page. You will also need to setup manually in case if you want to track the addition of items or removal of items from the product list or grids. This setup is manual because this is the best &amp; effective way to do [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/\" \/>\n<meta property=\"og:site_name\" content=\"HuntBee Resources\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/huntbee.opencart\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-10T04:57:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/\",\"url\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/\",\"name\":\"Default Template - HuntBee Resources\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/ga-default.jpg\",\"datePublished\":\"2018-11-26T07:40:24+00:00\",\"dateModified\":\"2023-02-10T04:57:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/ga-default.jpg\",\"contentUrl\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/ga-default.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/default-template\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Google Analytics Enhanced Ecommerce Tracking for OpenCart\",\"item\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Installation\",\"item\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/docs\\\/google-analytics-enhanced-ecommerce-tracking-for-opencart\\\/installation\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Default Template\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#website\",\"url\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/\",\"name\":\"HuntBee Resources\",\"description\":\"OpenCart Extension Documentations - Guides - Blogs - Projects\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#organization\",\"name\":\"HuntBee OpenCart\",\"url\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-mobile-logo-new.png\",\"contentUrl\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-mobile-logo-new.png\",\"width\":945,\"height\":200,\"caption\":\"HuntBee OpenCart\"},\"image\":{\"@id\":\"https:\\\/\\\/www.huntbee.com\\\/resources\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/huntbee.opencart\",\"https:\\\/\\\/www.instagram.com\\\/opencart.huntbee\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Default Template - HuntBee Resources","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/","og_locale":"en_US","og_type":"article","og_title":"Default Template - HuntBee Resources","og_description":"The ocmod adds the add to cart tracking script to the product page. You will also need to setup manually in case if you want to track the addition of items or removal of items from the product list or grids. This setup is manual because this is the best &amp; effective way to do [&hellip;]","og_url":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/","og_site_name":"HuntBee Resources","article_publisher":"https:\/\/www.facebook.com\/huntbee.opencart","article_modified_time":"2023-02-10T04:57:16+00:00","og_image":[{"url":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/","url":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/","name":"Default Template - HuntBee Resources","isPartOf":{"@id":"https:\/\/www.huntbee.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/#primaryimage"},"image":{"@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/#primaryimage"},"thumbnailUrl":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg","datePublished":"2018-11-26T07:40:24+00:00","dateModified":"2023-02-10T04:57:16+00:00","breadcrumb":{"@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/#primaryimage","url":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg","contentUrl":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2018\/11\/ga-default.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/default-template\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.huntbee.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Google Analytics Enhanced Ecommerce Tracking for OpenCart","item":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/"},{"@type":"ListItem","position":3,"name":"Installation","item":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/"},{"@type":"ListItem","position":4,"name":"Default Template"}]},{"@type":"WebSite","@id":"https:\/\/www.huntbee.com\/resources\/#website","url":"https:\/\/www.huntbee.com\/resources\/","name":"HuntBee Resources","description":"OpenCart Extension Documentations - Guides - Blogs - Projects","publisher":{"@id":"https:\/\/www.huntbee.com\/resources\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.huntbee.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.huntbee.com\/resources\/#organization","name":"HuntBee OpenCart","url":"https:\/\/www.huntbee.com\/resources\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.huntbee.com\/resources\/#\/schema\/logo\/image\/","url":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2020\/04\/cropped-mobile-logo-new.png","contentUrl":"https:\/\/www.huntbee.com\/resources\/wp-content\/uploads\/2020\/04\/cropped-mobile-logo-new.png","width":945,"height":200,"caption":"HuntBee OpenCart"},"image":{"@id":"https:\/\/www.huntbee.com\/resources\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/huntbee.opencart","https:\/\/www.instagram.com\/opencart.huntbee\/"]}]}},"comment_count":0,"_links":{"self":[{"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs\/892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/comments?post=892"}],"version-history":[{"count":5,"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs\/892\/revisions"}],"predecessor-version":[{"id":1764,"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs\/892\/revisions\/1764"}],"up":[{"embeddable":true,"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs\/870"}],"next":[{"title":"Journal2 Template","link":"https:\/\/www.huntbee.com\/resources\/docs\/google-analytics-enhanced-ecommerce-tracking-for-opencart\/installation\/journal2-user\/","href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/docs\/880"}],"wp:attachment":[{"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/media?parent=892"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.huntbee.com\/resources\/wp-json\/wp\/v2\/doc_tag?post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}