google-tag-manager

How can I set Analytics variables with Google Tag Manager from the server?

匆匆过客 提交于 2019-12-24 04:39:12
问题 I'm using Google Optimize for creating A/B tests. I'm using it in server side mode as in this guide: https://developers.google.com/optimize/devguides/experiments That guide shows an easy way of setting which experiment is running with which variant by rendering the JS code on the server which sets the experiment id and variant id: // 2. Create a tracker. ga('create', 'UA-XXXXX-Y', 'auto'); <?php <<<HTML // 3. Set the experiment ID and variation ID. ga('set', 'exp', '$experimentId.$variationId

Issue with GTM and asp.net webforms with two submit buttons

那年仲夏 提交于 2019-12-24 00:26:10
问题 Just wanted to share a discovery when using Google Tag Manager (GTM) and two submit buttons in a form-tag (common legacy asp.net Webforms tech). GTM is used by website editors. So the developers doesnt need to be involved when other scripts or event needs to be implemented or traced. The problem is that something in GTM is making our form to always trigger the default submit button (the first in order is default). Example problem/how to reproduce: in a wizard scenario, with back and next

Google Tag Manager delaying window.load?

家住魔仙堡 提交于 2019-12-23 07:11:37
问题 I have a page that fires an ajax call on load $(window).load(function() { updateDeliverySlots(); }); I also have Google Tag Manager javascript at the top of my body (I know the current suggestion is to place this in the head section, but we haven't updated the code yet, and don't think that is the source of the problem). <body> <!-- Google Tag Manager --> <noscript> <iframe src="//www.googletagmanager.com/ns.html?id=XXXX" height="0" width="0" style="display:none;visibility:hidden"> </iframe>

Google Tag Manager Rule to Identify Traffic Source

三世轮回 提交于 2019-12-23 04:32:26
问题 Is there a way to create a google tag manager rule ( via a macro ) which identifies the traffic source type? ( Like organic ?). Would like to create a tag which only fires if the source of traffic is organic. Possible? 回答1: Easiest way would be to extract the source (utmcsr) from the Google Analytics (__utmz) Cookie and fire an tag Manager event based on the value. Then create a rule based on that event. I don't think it's possible solely from the tag manager interface. (Updated to add) I've

Javascript - get image alt text of clicked link for Google Tag Manager

拈花ヽ惹草 提交于 2019-12-23 03:15:55
问题 I want to use the Javascript below capturing the alt attribute of an image when user click on it, but the result I can get is always null. I want to extract the "Youtube" alt attribute. <a href="http://www.youtube.com/" title="Youtube" target="_blank"> <img src="/example" class="example" alt="Youtube"> </a> function() { var elem = {{element}}, attr = "alt", // change to corresponding attributes result = (elem.getAttribute && elem.getAttribute(attr)) || null; if( !result ) { var attrs = elem

Javascript - get image alt text of clicked link for Google Tag Manager

≯℡__Kan透↙ 提交于 2019-12-23 03:15:11
问题 I want to use the Javascript below capturing the alt attribute of an image when user click on it, but the result I can get is always null. I want to extract the "Youtube" alt attribute. <a href="http://www.youtube.com/" title="Youtube" target="_blank"> <img src="/example" class="example" alt="Youtube"> </a> function() { var elem = {{element}}, attr = "alt", // change to corresponding attributes result = (elem.getAttribute && elem.getAttribute(attr)) || null; if( !result ) { var attrs = elem

Google Tag manager - Get parent of element in a javascript variable

时光怂恿深爱的人放手 提交于 2019-12-22 17:06:35
问题 In a custom javascript variable, how can you get the parent element of the clicked element? <div> <h2>Lorem Ipsum</h2> <a href="#"></a> </div> For instance, I want to go get the content of the <H2> when I click the <a> to log Lorem Ipsum when the <a> is clicked. 回答1: Seems the Click Element variable works great here. It was weird, I was using it in '' and that made it return only the url. But you can use it like a this function(){ var title = jQuery({{Click Element}}).parent().find('h2').html

GTM data layer eventCallback function

旧城冷巷雨未停 提交于 2019-12-22 17:06:24
问题 So i have Ecommerce code setup in GTM data layer, but after that is sent to Analytics i want the page to be redirected so i know i should be using eventCallback but it is not working for some reason. <body> <script> dataLayer = [{ 'transactionId': '56833', 'transactionAffiliation': 'TestName', 'transactionTotal': 1540.00, 'transactionTax': 385, 'transactionShipping': 0, 'transactionProducts': [{ 'sku': 'FFSS44HH', 'name': 'test', 'category': 'TestCategory', 'price': 1540.00, 'quantity': 2 }],

Fire GTM tag only if on homepage of the site

南楼画角 提交于 2019-12-22 10:55:22
问题 The homepage can also have extra GET params (e.g. utm tags and similar marketing variables). How can I make it work? Simple "end with http://example.com or http://example.com/" doesn't work cause the url might be http://example.com/?utm_campaign=text&... Thanks! 回答1: The best practice is always install the GTM along you domain and execute it whenever you need. To launch a tag only in the home you need to use the following trigger. Add this on you custom HTML tag, take care of the equals. 回答2:

Tracking events using Google Tag Manager

霸气de小男生 提交于 2019-12-22 09:39:15
问题 I've been attempting to pick up a bit of Javascript for analytics since starting to use Google Tag Manager. Currently, I'd like to track exit links and am using the following custom html snippet: <script type="text/javascript"> $(document).ready(function(){ $('.app-cta a').onClick=_gaq.push(['_trackEvent', 'App', 'Click', 'iOS']); }); </script> The firing rules are: {{event}} equals GAevent I then tried a firing rule: {{url}} matches RegEx .* No luck. Nothing being picked up in Google