Setting up Adobe Analytics eCommerce tracking in GTM - google-analytics

I am currently in the process of setting up Adobe Analytics on a website that is currently using GTM & GA (universal analytics). Ideally I want to leverage the existing data layer to pass values to the Adobe evars/props but the one question I have was how to handle the products field? Adobe requires the products field to be in a very specific format (category;product;qty;total).
Can I build this product string in GTM? Or do I need the developers to hard code this string? I might be overthinking this but I have never installed Adobe thru GTM before

You can use a custom javascript variable (GTM "variables" used to be called "macros" which was a lot less confusing) of the type "custom javascript function" to loop through the products array and assemble the product string.
That is you'd first create a dataLayer variable that returns the product array from the dataLayer and then do a loop; a custom javascript variable in GTM is an anonymous function that returns a value. This would look a bit like that (from top of my head, not exact code; the thing in curly brackets is the datalayer products variable you need to create first):
function() {
var products = {{products}};
var productAdobe = [];
for(i=0;i<products.length;i++) {
prod = products[i];
productAdobe.push(prod[i].category + ";" + prod[i].id + ";" + prod[i].quantity + ";" + prod[i].quantity*prod[i].price);
}
return productAdobe.join("\n");
}
Like I said this is not exactly working code, but should be enough to give you an idea.
Having said that having your developers pass on a proper product string is a much better idea. Using GTM for programming tasks is error prone and makes maintenance hard (and tag management should make your life easier, not harder). And if you already have Adobe Analytics you should have free Access to Adobe DTM which might a better choice to deploy Adobe Analytics (for one thing you cannot host s_code within GTM, as the custom HTML tag has a length limit that is exceeded by the Adobe Tracking code).

Related

Why can't I create a Google Analytics property view?

I'm trying to use Google Analytics as a data stream for Google Data Studio but it requires me to have a property view. There is no option for me to create a view in my property in the administration page:
There is no column named Views:
Is there something I need to do to be able to create new views?
OBS.: My Google Analytics account was imported directly from Firebase.
Google Analytics is changing and it is a bit confusing. I will try to clarify it for you. As far as I have gone, evolution has been:
1.- "App + web property" (Beta phase)
2.- "Universal Analytics" (*) (until 14-Oct-2020): It is identified because the account number is preceded by "UA-" eg. UA-123456789 (Attention, sometimes it is not very obvious and you have to create a new user to see the UA prefix). This option is only suitable for the monitoring and analysis of Web pages and has the option of analysis using "Views" enabled. If you don't have it, you should:
2.a.- Create a new "Property"
2.b.- "Show advanced options"
2.c.- Activate "Create an Analytics Property"
2.d.- Create only one "Universal Analytics" Property
3.- "Google Analytics 4": It is identified because the account number is preceded by "GA4-" eg. GA4-123456789. In this case, the analysis is not done through "View" but through "Data Stream" (** incorporating a series of improvements) although Google offers the possibility of creating two "Properties" one in UA format with Views and another in GA4 format with Data Stream
In all cases, you must place the corresponding gtag provided by Google Analytics within the tag of the page you want to analyze.
Sources
(*) https://support.google.com/analytics/answer/10089681?hl=es&utm_id=ad
(**) https://support.google.com/analytics/answer/9216061?hl=es&utm_id=ad
https://support.google.com/analytics/answer/9367631
https://support.google.com/analytics/answer/9539598?hl=en#:~:text=If%20you%20set%20up%20a,with%20%22UA%2D%22).
This is a good answer to that question. I had the same problem. In case the URL doesn't load, essentially,...
"If you set up a Google Analytics 4 property with a Web data stream, you have a Measurement ID (which begins with "G-").
If you set up a Universal Analytics ("Web") property (Universal Analytics properties have views instead of data streams), you have a Tracking ID (which begins with "UA-")."
You cannot have the property be a Google Analytics 4 property with a web data stream and have a view page as well. If you want the View page, then when you create the property, make sure its Universal Analytics.
Hope this helps, I'm new to this game.

Google tag manager how to split an array and send the data seperate with one tag

Im trying to extract parameters from the URL. Then send that data to google analytics via GTM. Using only one tag instead of having mulitple tags for each parameter.
website.com/index?searched=data%7Cdata%7Cdata
The data needs to be seperated. So I've created a variable that seperates each paramater.
function () {
var x = {{URL Query}}.split("|");
var z = x.slice(1, -1);
return z;
}
And a trigger that picks up on click.
I'm fairly new to google tag manager, and i'm unsure of the process to do this. Should I work with Datalayers or do a loop with Custom HTML tag? But then i'm not sure what the code is to send my data to google analytics.
What you need to do is to create multiple variables if you want to capture different parameters in the URL to separate dimensions in Google Analytics. When looking at your code I can see that you want to get the last value separated by "|". Take your code, place it within a "Custom Javascript" variable and then in your Google Analytics tag you can just map the variable to whatever dimension you have set up for this purpose.
Lastly, if you want to pick up more parameters in the URL, just create a a new Custom javascript variable, capture the parameter then map it to another dimension in the Google Analytics tag.
Hope this helps.

How to Track Store Locator Search terms in Google Universal Analytics

I am in the process of setting up enhanced Ecommerce for GA and have had a few requests of additional of what else the client would like to see in their reports. Once of which is
"Where can i see a report if the locations that a use types in when they use the store locator"
There is already an internal search functionality thats been set up and is tracking the search terms people are typing when looking for products, but i'm not sure if i would need to set this up as a second search terms report or if it's something different?
The URL of the page is different to the internal search results and is www.domain.com/store-locator#wales|GB|0|0|0
Any insight into this would be really helpful.
Thanks,
Roxi
As to me knowledge, you are not able to use bookmarks (#something) in GA for internal site search setup. Only GET and POST parameters are allowed. In your situation I think the best solution is to use GA events to send the data about used location each time the user is using this functionality. You need to include addition ga() function call to track those events. Info about how to set it up you could find here: event tracking. After setting things up, you will see all the info about number and type of called events in Behavior -> Events reports section in GA.
Example code:
<button onlick="var hash_location=window.location.hash;ga('send','event','Locator',has_location)">Click me</button>
With such function new event will be send to GA with Event Category=Locator and Event Action=hash in the url. You have some complicated hash, so most probably you need to extract first some info from this using regular expression. Example to get first item from |-separated list in the hash:
var pattern = new RegExp('[^#|]+');
var hash_location = pattern.exec(window.location.hash)[0];

Integrate optimizely into google analytics

I have been trying to integrate optimizely into google analytics and it has proved a bit difficult than I anticipated. I am doing it through gtm which makes it slightly complicated. I have created a macro
function() {
dimension = optimizely.allExperiments[experimentId].universal_analytics.slot;
experimentIds = optimizely.activeExperiments;
variationName = optimizely.variationNamesMap;
experimentDetails = variationName + "|" + experimentIds;
return experimentDetails;
}
and joined it to a custom dimension in universal analytics tag which means this will be fired on every page but the dimension always comes back as:
'Running command: ga("set", "dimension14", undefined)'
I will really some help on this as I am struggling and the optimizely team dont know what to do either.
Thanks.
While Optimizely is best installed directly onto your page, it is possible to install Optimizely using Google Tag Manager (GTM), which is discussed here, with a complete walk through. This will ensure Optimizely fires before GA (or any other tag):
https://help.optimizely.com/hc/en-us/articles/200040095-Implementing-the-Optimizely-Snippet#tag_manager
The next part is troublesome - how can you integrate Optimizely with Google Analytics? To do so, you must insert a line of code before the GA tracking call is made ( ga('send','pageview') ). To do this, you must modify the JS in the GA call to look like the code below.
Please note, unless GTM allows you to modify their GA add on, you will need to add a custom integration in GTM for GA to place the modified code.
// Optimizely Universal Analytics Integration code
window.optimizely = window.optimizely || [];
window.optimizely.push(['activateUniversalAnalytics']);
ga('send', 'pageview');
The 'activateUniversalAnalytics' call is similar to the macro you've written above, where all it does is pass your experiment ID# (or name) and the variation # (or name) to the custom Dimension you've assigned to GA in Optimizely. One benefit of using Optimizely's integration is you can change the Dimension number per experiment inside Optimizely without making any changes to your page's source code.
If you need further assistance with this, please contact support#optimizely.com (full disclosure, I am an Optimizely employee).

How to use url_path in Google Tag Manager to track directories

I want to have content groups in Google Analytics and I'm using Google Tag Manager to implement them. The way to do it, according to their reference, is to create a lookup table that is using the url_path macro to filter URLs. The url_path only gives the path of the URL, stripping the end of it, so for a url http://www.example.com/hello/index.html the result would be /hello/.
I want to group my users' account pages which are like: http://www.example.com/accounts/profile/user1/
The problem with the above macro is that it would return /accounts/profile/user1 which is not what I want. I only want to keep /accounts/profile/.
How could I accomplish that using this macro?
For helping you, in GTM you just have to configure the "Content Grouping" part (and take special care of the index that you put in). All the stuff is on GA Backend, where you declare your content group and which give you an index for each content group (index that you have to keep in GTM).
For some GA account you have to wait around 48 hours till you got some data, if your hit is ok you can see your content grouping information in the variable utmpg (like :" 1:Accueil,2:Page de destination | Actualité | ---,5:www.ouest-france.fr/home" for example).
Hopes it will help you to understand.
Fanny

Resources