How can I load google optimize on a dataLayer change or evaluate on a custom event? The interface has changed and I don't see how to set this up so that:
window['dataLayer'].push({'event': 'optimize.activate'});
Will work? The targeting requires a page url and also have it set to look for variable optimize contains true.
Yes, it is still possible. You can find this option at the very bottom of the page, within the Settings block. It is called 'Activation event', and you can select Page load or Custom event. The second one is which you are looking for.
As you have mentioned, you still need to provide at least one rule, that refers to some URL settings.
Related
I have a multilanguage site and my plan is to track every language apart.
Example:
domain.com
domain.com/en/
domain.com/de/
domain.com/fr/
For now, I have one GA Property and one GTM Container for the whole site. I was thinking of creating multiple Properties in GA for every language and one for all together. So that would look like this:
domain.com -> GA-1
domain.com/en/ -> GA2
domain.com/de/ -> GA3
domain.com/fr/ -> GA4
Now in GTM I would add to the container one Tag for each Property and create a trigger for each property. GA-1 trigger fires on all pages, GA-2 trigger fires on some page views that page path contains /en/, GA-3 trigger fires on some page views that page path contains /de/...
Is this the best practice and would this work like this? or is there another method to achieve this goal? Or is it enough to create some Views in GA and create some filters for each language?
The goal is to track every language in a different property so the starting point is always the language. Maybe there are also different conversions in the properties.
In this situation, the best practice is to only have a single GA property that tracks the whole site. If you then want to only report on the data from a specific section of your site (i.e. a specific language) then you would use GA views (and filters) to achieve this. You would filter based on the Page dimension (e.g. Page starts with /fr).
There is no benefit to creating a property for each language except maybe to prevent you from going above the 10 million hits per property per month limit of the free version of GA. On the other hand, there is a benefit to tracking the entire site in a single property. The main benefit is that it allows you to perform cross-language analysis.
I would like to add another solution to your question, where you can actually get the result you're asking for (even though it's not best practice).
If you go to Variables > User-Defined Variables -> New
Let's give the variable a name like UA - Tracking ID
You can choose variable type RegEx Table
Set the Input Variable to {{Page Path}}
And set the rows you need to the following:
Pattern
^/en/.*
^/de/.*
^/fr/.*
Output
GA-2
GA-3
GA-4
Under Advanced Settings
Check Ignore Case, and uncheck Full Matches Only and Enable Capture Groups...
Now add this variable {{UA - Tracking ID}} in your Universal Analytics tag under Tracking ID.
This will work on the tracking for each language.
When that's done, I will just add an extra Universal Analytics under Tags that tracks all the pages with the tracking ID GA-1.
Now two tags will be fired on eg. domain.com/en/, one for the combined domain GA-1 and one for the separate domain, in this example GA-2.
I need to implement the GA tracking event for PDF file downloads, For that had searched a lot and found out many code where i can add some code to links and track them from GA's content section, But the problem is I do have a lot of PDF link on the page and don't want to edit every link and I want the code to be generic for future uploaded links also.
So what would be the best approach for this task, Any referral links would do or any code would be highly appreciated .
Thanks in advance.
You can explore the use of Google Tag Manager, where you can create a generic tag that will return to you information for each individual link. GTM uses things called "macros" which is like a template that returns useful information including the clicked element's ID, or pathname (which in your case for the PDF files, would all be different). So in this way, you would only need to call this macro each time a PDF file is clicked. No coding is involved using this standard approach through GTM. Here's a link to a descriptive explanation: http://porcelainduck.com/2014/03/track-pdf-downloads-google-tag-manager/. You can see that it uses the {{element URL}} macro that returns the PDF's unique URL. GTM not only applies to current links, but also all future links.
Based on the tags which you've used to mark your question with you're using C#, ASP.NET
If that's the case, can't you create a base page that on rendering replaces all the
I would recommend adding a click event with JQuery to all links or all links inside the download widget class. Inside the click handler I would then grab the link text and use that as part of the Google analytics event you fire.
I'm just getting started with splittesting using Google Analytics (GA). Rather then using different URLs for different versions of a page I want to use the same URL and differentiate the versions via GA custom variables.
I've managed to accomplish this in my Django project with a conditional in the view-layer that loads up different html templates for different versions and the html-templates also take care of setting the custom variables.
However I think that it would be a lot cleaner to have all of my splittest code in a javscript file that:
1) Sets/reads a cookie on the browser specifying which testing bin this browser is in.
2) Modifies the page html and css to create the different versions
3) Records the version in a GA custom variable
Right now I'm setting all of my custom variables right in the code snippet that I've copy-pasted from GA.
My question is simply: Can I set the custom variables later in the page buy a _gaq.push(), or do they need to happen before the anonymous function that ends the snippet from GA?
Custom variable data gets recorded when GA makes a tracking GIF request, which occurs with _trackPageview or _trackEvent.
So, you can set the custom variables anywhere in the page, as long as there's a _trackPageview or _trackEvent somewhere afterwards.
I have two views loaded on the front page. Both contain exposed filters which when modified, display different content (done using the Better Exposed Filters module).
When modifying one view the URL will be http:example.com/?cid[]=1 and the changes will take effect.
When modifying the other view the URL will be http:example.com/?type[]=marketing_item and the changes will take effect however, this will reset the first view (this problem also happens when reversing the process).
Am I missing something or is this type of functionality not possible?
Process $_GET['cid'] or $_GET['marketing_item'] in argument handling code of your views...
On stackoverflow, and other websites, if you start making a change to form elements and then you try to navigate away from the page, you will get a confirmation message asking if you are sure you want to discard your changes.
This seems relatively easy to do by hand, but impractical to apply across an entire site. Is there any generic solution that can be plopped onto a page as a control (or even jQuery plugin) which will track IsDirty for all fields (without having to specify each field by hand)?
You can use the window.onbeforeunload event.
See also How can I override the OnBeforeUnload dialog and replace it with my own?
A possiblity would be to clone a selection of all your inputs when the page is loaded (and data into it as well).
You could then do a compare as desribed here:
http://chris-barr.com/entry/comparing_jquery_objects/
Word of warning though, this may be costly, performance wise.