e-commerce,google-tag-manager,google-datalayer , Google Tag Manager and dataLayer interraction

Google Tag Manager and dataLayer interraction


Tag: e-commerce,google-tag-manager,google-datalayer

I use GoogleTagManager script and dataLayer object. I read in documentation that dataLayer object has to be filled above the GTM script. But I need to add a product detail when the user chooses the product and it happens after the GTM script is loaded. If I use dataLayer.push(chosenObject) will this action call the Google Tag Manager script? Will it work?


Yes, you can push variables to the dataLayer at any time, the "trick" is in how to access the data from the dataLayer in your tags (plus if you declare you dataLayer above the GTM code you do not call "push" - you declare it as a variable so you can push later).

It's necessary to declare the data in the dataLayer if you want to use it as soon as the page loads - the standard pageview trigger will run as soon as the GTM code has loaded (i.e. before the page has finished loading), so obviously GTM can only access data that preceeded it in the code.

Triggering tags in GTM takes an event (do not confuse with Google Analytics events or Javascript events, event in GTM is just a reserved variable name).

A few events are produced by GTM implicitly - the pageload-event, DOM ready, click and submit events.

If at some later point you want to trigger an element to respond to a value you pushed to the dataLayer you need a custom event:

 'payload' : 'this is my data'

(please not that data comes in key->value pairs).

Now you can have a trigger that fires on the event i_pushed_a_value, and you can use a custom variable of the type dataLayer (enter the key, in this case payload, as key in the variable configuration) that holds your data.


Replacing variable A that contains document.location.path if variable B is not undefined

Google Tag Manager in default configuration sends a pageview based on a variable {{Page URL}}. This variable contains document.location.pathname. The website I'm working on has a global js variable trackerParam that modifies the page URL sent to different analytics engines. In most of the cases, it's undefined. What I need...

Mailchimp Ecommerce360 Javascript Implementation

Wondering if anyone can provide an example of how to pass a request to the /ecomm/order-add function of the Mailchimp API using javascript. This is critical for making use of Mailchimp's Ecommerce360 tracking. Here is documentation from Mailchimps API: https://apidocs.mailchimp.com/api/2.0/ecomm/order-add.php...

Algorithm/formula to calculate Product ranking on a ecommerce website(Based on following criteria)

I have been Working on algorithms and formulas to find out a score for the products available on my ecommerce website.Basically, I want to calculate some kind of score to rank the products when a user searches it. I'll give some background on the criteria i am planning to define...

payment module not working in magento

I have a magento store, and it's payment module is not working. I can add my shipping method, but after submitting shipping method, it won't proceed to payment mode, I have enabled cash on delivery. and I have an amazon payment extension also. When I checked in console, there shows...

Implementing Google Tag Manager into Android

I am trying to implement Google Tag Manager by following this tutorial: https://developers.google.com/tag-manager/android/v4/ When I run the application, I get in the console these errors : 05-22 12:27:44.490 V/GoogleTagManager﹕ Attempting to load a container from the resource ID 2131099650 (testconverteo.ismail.converteotag:raw/gtm_default_container) 05-22 12:27:44.520 E/GoogleTagManager﹕ Invalid macro: _gtm.loadEventEnabled 05-22 12:27:44.520 V/GoogleTagManager﹕ loadAfterDelay:...

Is it a good practise store the checkout steps fields in php $_SESSION?

I have my e-commerce site with three checkout steps, each button to continue is a POST action and redirect to the next step: if the user navigates by the checkout steps (click on the previous button for example), the form fields don´t show the data posted previously. This form fields...

Google Tag Manager for staging environment and production

Just a simple question here as I'm new to GTM. We have the staging environment at xxx.company.com and the production environment at xxx.com Both sites use the same source code of course, so the same GTM account and same script. How can you add scrips via GTM only to the...

GTM Macro to set GUA_ID based on domain/hostname/url

We have several websites. During set-up of GTM I was wondering if I needed to set-up 1 GTM-container for alle websites (and make it variable) or set-up 1 container per website. The latter seemed like a lot of manual config. However, to achieve a more dynamic approach I was wondering...

Tracking AppView events in GA via Google Tag Manager from iOS

I am trying to get GA Screens working via Google Tag Manager on iOS. I've configured GTM Tag with the tracking type App View and I am able to see that events are coming but screen name is always (not set) I was trying to set different variables/parameters in GTM...

Should Tag Manager's snippet be officially entered into the head or body?

Google Analytics' https://support.google.com/analytics/answer/1008080 states: Paste your snippet (unaltered, in its entirety) into every web page you want to track. Paste it immediately before the closing tag. But what about Tag Manager? Is there an updated official documentation about whether it should be in the head or body (and where exactly...

How can I allow users to get paid directly with stripe?

I've looked at stripe connect and it forces each user to impute their Social Security number and etc. just so they accept payments for a item they want to sell. Is there a less painless method where users can sell something on my site, receive monies, and buy from other...

ElasticSearch in e-commerce: multiple categories for a product

How do you index products like that in ElasticSearch? We've separated all documents based on the attributes (colour, brand, size, whatever users input), but all of them belong to a set of categories. May be one, may be 15. [0] => Array ( [product_id] => 123456 [product_name] => Shirt 1...

Google Tag manager code added with the help of DTM is not working

I had a request to add Google tag manager to our website and i added it using Dynamic Tag Manage (DTM). I created a page load rule and added this script. But my client is saying it is not working as DTM adds the code to the page with an...

Broadleaf - Extending DemoSite Admin - Add new Menu and Page

I have been looking into Broadleaf since last couple of days. I have managed to run it on local tomcat with MySql. I have extended Entity for my custom requirement following Broadleaf's documentation. Now I want to add a menu option (in left menu) in admin. I have no clue...

FrontEnd Magento Hello World Not Working

Please help with this newbie magento tutorial, I've been struggling with this for 2 days.. Using XAMPP 1.7 and magento 1.9.1... I already create the magento directory & file structure like this: -htdocs -magento -app -code -local -Practice -Mymodule -controllers IndexController.php -etc config.xml -etc -modules Practice_Mymodule.xml And this is the...

Prestashop 1.6 product_list: get number of attached attribute combinations

I'm building my first prestashop. I have a couple of products with attribute combinations that have an impact on the price. In list views, I would like to detect if a product has more than one combination attached to it, in order to display a 'from' before the price. I...

403 Error when trying to remove products from Cart

I am using a cPanel host and running PHP 5.5. Opencart version 1.5.1. When I try to remove a product from the cart I am getting a 403 forbidden error. This only seems to happen with products that have a lot of options and include text input options. I have...

Display item list in shopping cart using PHP

With the foreach loop I'm trying to connect to my database and display in a list the products that have been added to the cart. Each product has a product ID which is correctly working and being stored in the session variable through the cart.php. I can't figure out how...

Unable to call magento admin controller

I have created a custom module that adds two menus in catalog. I have also created a controller for one of the menu , but the controller never gets called but instead is redirected to the admin dashboard page. My question is some what related to this question Magento admin...

UA through GTM macro: ga.getAll()[0].get('clientId') - ga is not defined

Here is the site - http://www.ssangyong-favorit.ru/ For some reason this code is giving me "GA is not defined" error: ga.getAll()[0].get('clientId') This site has Google Analytics installed on it through GTM and it works and getting stats. The code works for any other site just fine. The problem is that "ga"...

Find header of Clicked Radio Button

I've just started with Google Tag Manager and I needs a bit of help. I wanna build it all with Jquery and it would work something like this: $('input[type=radio]').on("click", function() { dataLayer.push({ "event":"Google Event", "eventCategory":"Google Category", "eventAction": "Event Action", "eventLabel": "Desired Label of Radio Button" }) }); Now what I...

Supplier login when using spree-drop-ship

I'm working on a marketplace website. The idea is to allow for suppliers to login, add their products, view orders, generate reports etc. I'm using Spree Commerce, and I see everyone suggesting to use spree-drop-ship extension to achieve all/part of above.(it's not really clear from the documentation, all the features...

Displaying all woocommerce product liks with title in Footer for SEO - Wordpress PHP

I am wanting to display all woocommerce products with links with the woocommerce title on the links top help my SEO. I have managed to find some code below which gets the product categories but cant seem to get the code to display all products with the title on the...

Native Mobile app for presta shop [closed]

I want to develop a native android application for my PrestaShop store. I have been searching on Google for a while but all i found was third party applications that says they can create an application for mobile. The documentation doesn't provide a clear answer as well. Does prestashop provide...

Google Tag Manager Dynamic Function

Is there anyone who knows how to use dynamic function in Gtm. For ex I create a new variable(custom javascript in GTM) called GetName and which is just take 1 parameter. function(name) { console.log(name); return; } Now, I want to create a new custom javascript. And that will call the...

Detecting a server conversion in Google Tag Manager

Can I - and if so, how do I - detect in Google TM either one of these cases: A new HTML element (in this case, img) was suddenly appended to the webpage. A certain JavaScript AJAX command was suddenly launched and returned a success (with a non empty data)....

Google Tag Manager - what about scripts in the footer?

On our site we have script tags for third-party services like Lotame, Peer39 and Google Analytics in the footer just before the closing body tag, to avoid blocking the page render. We make scripts defer or async wherever possible, but some of the services don't work with asynchronous loading and...

Google Tag fires but not logged in Analytics

I had set up my Google Tag to track clicks on spans with certain IDs, the events are firing according to WASP extension, but they are not showing up in my Google Analytics account. Here is my trigger: My Tag: WASP in action: GA displays pageview only: Code is installed...

Why Google Tag Manager puts both display:none AND visibility:hidden on iframe?

If you take a look at the <noscript> part of the Google Tag Manager embed code, you'll notice something like: <noscript><iframe style="display:none;visibility:hidden" src="//www.googletagmanager.com/..." height="0" width="0"></iframe></noscript> I can understand why style="display:none" would be important (it will hide the element such that it takes up zero space in the layout and yet...

Universal Analytics events via Tag-manager not working

I'd like to have any help regarding an events-firing issue with Universal Analytics deployed via Google Tag Manager.In particular, I'm attempting to send two kinds of events on the same page: a checkout-purchase event (Enhanced-ecommerce) and an onclick generic custom one. Below my page's related code, in the order of...

How to open a lightbox on page load if url equals using google tag manager

The title pretty much says it. I would like to show a lightbox on page load only if the url is www.example.com/#popup versus www.example.com If this could be accomplished with google tag manager that would be grand I've see bits and pieces of this but I'm having trouble piecing it...

PHP Comparison Inversion

Following code is from an excommerce shipping module: if (!IS_ADMIN_FLAG) { global $cart; $chk_products_in_cart = 0; $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '12'); $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '22'); // do not show florida 18 and new york 43 $chk_delivery_zone = $order->delivery['zone_id']; $chk_states = '18, 43'; $arr1 = explode(", ", $chk_states); $arr2 = explode(", ",...

Prestashop 1.6 Module error: Notice on line 719 in file prestashop16\tools\smarty\sysplugins\smarty_internal_templatebase.php

I'm developing a module and extended AdminFeaturesController.php to display my custom field Add/Edit Feature Value, but it is showing following error in popup: Notice on line 719 in file D:\xampp\htdocs\prestashop16\tools\smarty\sysplugins\smarty_internal_templatebase.php(157) : eval()'d code [8] Undefined index: value I think it is due to I override the function initFormFeatureValue() in my...

Prestashop 1.6 display custom field in Feature Add/Edit form

I am able to display my custom field in Feature Value Add/Edit form by overriding AdminFeaturesController and overriding initFormFeatureValue() function. I want to do the same for Feature Add/Edit form but cannot find function to override. I tried renderForm() function but didn't work. Which file/class/controller/function should I look into to...

Google tag manager v4 tracking screenView issue android

I am using this GTM utils function to push screen event, and I am sending Screen Name as a second paramater public static void pushOpenScreenEvent(Context context, String screenName) { //ContainerHolderSingleton.getContainerHolder().refresh(); DataLayer dataLayer = TagManager.getInstance(context).getDataLayer(); dataLayer.pushEvent("openScreen", DataLayer.mapOf("screenName", screenName)); } And calling this function in activity like this @Override protected void onStart()...

How does Google analytics measures page load time for virtual pages sent?

I have bad performance results in Site Speed Page Timings in Google analytics, for virtualPage, but I can't find way, how does this time is measured (e. g. I do not see parameter in dataLayer object, responsible for timing, or parameter in collect request sent). Moreover I do not have...

Magento realtime data integration

this could possibly be answered somewhere allready, but unfortunately I could not find the answer that would suit me. The question is, can Magento be used only as a front end E-Commerce platform? That is read product nad customer data from external API, and also submit that data to external...

How to specify what “list” the product was added to cart from? Enhanced Ecommerce

Trying to implement Google Analytics Enhanced Ecommerce tracking for my website. How to specify what "list" the product was added to cart from? Here is the standard tracking code for adding the product to basket: // Called when a product is added to a shopping cart. function addToCart(product) { ga('ec:addProduct',...

Updating fields of model using forms and views on Django 1.7

In models.py my Product model is class Product(models.Model): productName = models.CharField(max_length=20, default='1',blank=False,null=False, primary_key = True) userPhone = models.CharField(max_length=20, default='1') userid = models.ForeignKey(Account, default='1',null=True) productDesc = models.TextField(blank=False,null=False, default='1') productCategory = models.ForeignKey(Category, null=False, default='1') productPrice = models.DecimalField(default='0',blank=False,null=False, max_digits=6, decimal_places=2) picture =...

How to remove LineItem instance from an order (Spree)

I'm working with Spree, but I'm not completely familiar with the built-in methods. I'm trying to make it so that when params[:quantity] == 0, the line_item instance gets deleted and removed from the order. I've tried calling destroy! on the instance but that hasn't worked, as well as a few...

Google Tag Manager and dataLayer interraction

I use GoogleTagManager script and dataLayer object. I read in documentation that dataLayer object has to be filled above the GTM script. But I need to add a product detail when the user chooses the product and it happens after the GTM script is loaded. If I use dataLayer.push(chosenObject) will...

Uploading products from excel file

I was wondering what is the best way of importing products into database. Product names have unique sku's. The Excel file may contain existing sku's. One way of doing import is: Read record from excel Check sku for existence in database table if already exists, update it or if not...

How to find Tag Manager Container ID with JQuery

I need to find what the Google Tag Manager container ID is after the page loads. I cannot get it from the same source as i'm adding it to the page. i want to set a jQuery variable to GTM-XXXXXX i have been messing with var scripts = $("script"); but...

How to show count of any jstree in google analytics

I am using google tag manager to fire tags for my website, I created custom javascript variable which returns count of my jstree selection (i.e how many users selected how many items) and i placed a trigger on this count, just wanna know if there is any way that i...

Can you use google tag manager to implement custom animations in a mobile app?

I was wondering whether it's possible to use google tag manager to implement custom app UX or UI without having to push a new version of an app? I see that you can use GTM to add tracking code without re-deploying, but can you say push a survey pop-up action...

Why isn't my Google Tag Manager event listener being installed?

I have a very simple Google Tag Manager trigger that looks like this: I also have a corresponding tag that uses this trigger. I have published my container, and the tag shows up when previewing/debugging the container: I also see my link's id in the response from GTM. However, I...

Google analytics (via tag manager) loses track of adwords visitors after first pageload

I am experiencing a very strange problem with Google tag manager (GTM), Google analytics (GA) and Google adwords. So far I am getting nowhere with solving it. The setup: We have a singe page application (backbone and marionette) and we are using GTM to push virtual pageviews to GA using...

Dx trouble writing output: already prepared… - Error in console

braintree-api-1.6.1-full.jar android:minSdkVersion="14" android:targetSdkVersion="18" I need to implement braintree inside my android app which has no issues, but as I copy the braintree jar file, into my projects libs folder and import the necessary classes, my app crashes. Full error message in console: Dx trouble writing output: already prepared [2015-06-18...

How can I turn dataLayer.push into a Google Analytics Goal?

I like to turn window.dataLayer.push({ 'event': 'Offer', 'vpv': '/offer-lead'}); or window.dataLayer.push({ 'event': 'Offer', 'eventCategory': 'Success', 'eventAction': 'Lead', 'eventLabel': pageId}); into a GA Goal that shows people who I count as "leads". I managed to catch this event in TM but not in GA. Can you please take me to the...

Google Analytics duplicate transaction id multiple domains

I am implementing Google Analytics (via GTM) on multiple ecommerce sites. I need to record transactions to the client's google analytics account as well as to our single master analytics account, which accrues data for multiple sites. I am wondering if there will be any issues sending duplicate transaction ids...