Can I Use a Custom Data Layer Name in GTM? [closed] - google-tag-manager

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am coming from Adobe world here - do I need to call my data layer "dataLayer" in GTM? Or can I define my own? And if so, where - in the GTM snippet?

You can! Yes, in the snippet. Google mentions this in their documentation.
From Google's example:
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','myNewName','GTM-XXXX');</script>
All you have to do is change myNewName near the end to whatever you want.
Make sure you do NOT change the occurrence of dataLayer right in the middle of the snippet. This is part of the snippet's logic to see if you are using a different name for the data layer. If the name you chose does not equal dataLayer, it adds a query parameter to the URL of the gtm.js script, to tell it what name to use. Otherwise it defaults to dataLayer.

Related

getstaticprops nextjs fetch all page at first time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
500 brothers. why nextjs fetch all json files at the first time I land on the page. I am used getstaticprops for those pages. I am afraid that will affect the performance.i expect that the json just should be fetched when I land on that page.
enter image description here
Your problem is you're using Link and by default, Link has prefetch={true} which means your page will prefetch all your data from all other pages' links. You can check this doc.
These prefetching behaviors run in the background, so you don't need to worry about performance.
If you are still concerned about it, you can set Link like below
<Link prefetch={false} href={...}>
<a>...</a>
</Link>
Side note that whenever you hover on Link, it will start prefetching, although you set prefetch={false}.

Create multiple custom Event Labels in Google Tag Manager [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to Capture 2 Event Labels in Google analytics (Label1 and Label2). When I set them in Google Tag Manager as Label1, Label2 the event gets triggered as a single Event label. I have also tried with other delimiters (, : |). In Google Analytics the Event Label is always capture as a single label. Is there any other option where I can map multiple custom Event Label for a Google Tag.
In Google Analytics a single event can only have one label, you cannot assign more than one label to a particular event. You might want to use some string value as a delimiter, like label2|label3|labelN and then use regex/filter in your report to address specific cases.

setting document.referrer on Landing page using Google Tag Manager [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Can you please guide me in setting up a Custom dimension which stores document.referrer only on the entry page of the website. So, this value remains same throughout the whole session.
At the moment problem for me is Document.referrer is being updated with the new value of the previous page.
Any help with clear explanation is highly appreciated.
cheers!
document.referrer is read only. You shouldn't be trying to overwrite it with the value from the first request. Browsers will handle this unexpected action differently.
By the sounds of it, you want to use a session cookie or sessionStorage to persist the first page url of the session. GTM can access both. sessionStorage or localStorage is preferred as it does not require sending any additional info with every request like with cookies.
Have a read of this one: https://www.simoahava.com/analytics/two-ways-to-persist-data-via-google-tag-manager/
To add as a custom dimension to GA, you'd want to create a new Variable of type Custom Javascript, which contains a function that reads the value from your persistent storage, then add the Variable to your GA tag.
Read more about custom dimensions here: https://support.google.com/analytics/answer/6164990?hl=en

What happens if you remove ga('send', 'pageview');? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
By a mistake I managed to remove ga('send', 'pageview'); from one of my pages. And it has been like that for a while...
Out of curiosity I wonder how important this line is, and what it actually does?
Obviously, a pageview will not be tracked for that page, but will other stuff be tracked?
What about sessions, users, etc.? Will that be tracked if this line it omitted?
If you wonder how I could forget this line on one of my pages, it is because I copy & pasted it from the index.html of a dynamic webpage that uses angulartics, and this line is not supposed to be used then.
Help appreciated!
If you remove that line, nothing will be tracked.
The only way to track things with analytics.js is to make ga('send', ...) calls. If you make no send calls, then absolutely nothing will be tracked.
Unlike what many people seem to think, analytics.js doesn't send anything to Google Analytics unless you explicitly tell it to.

Change link color or link CSS in Google Maps API [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm using Google Maps as an API to display a map on a client page. In the info window when the user clicks a marker I want the user to select that particular location and proceed to next page. Works fine with a link, however, visually this link gains to little visual weight. I want it to stand out more.
Is it possible, and if so how, to modify the styling of the links in the info window in the Google Maps API?
You set your infowindow content like this:
infoWindow.setContent("<div><a class='link' href='#'>...</a></div>")
So you can easily use the CSS selector to style the link.

Resources