How to send events in Adobe Analytics using GTM - analytics

I am using GTM to fire Adobe Analytics scripts on all the pages. It is working as desired. However I am wondering if is there a way to set up click events with no page refresh, in the same way as Google Analytics click events are set up. I am using s.tl() call however it is not sending the events to adobe omniture. Any thoughts on this. I know if I use DTM, it can be setup easily.

Assuming that you have Adobe Analytics already present on your website, s object is already present on your website. All you need to do is to put these codes on your website and fire this using GTM as a custom HTML Tag on basis of the trigger you require. There are standard events like gtm.js, gtm.dom and gtm.load already present. You can create your own custom event on top of this on basis of elements load. Using the same event you can fire these lines of codes on your website and this should give you what are you looking for.
<script type = "text/javascript">
var s = s_gi('yourreportsuiteID'); // replace this with your RSID!
s.visitorNamespace = "yournamespace" //optional
s.trackingServer = "yourtrackingserver" //optional
s.trackingServerSecure = "yoursecuretrackingserver"//optional
s.events = "event35";// your event number has to be activated in Adobe
s.linkTrackVars = "events,eVar38";//your eVar number has to be activated in Adobe
s.linkTrackEvents = "event35";
s.eVar38 = {{GTMVariable}}
s.tl( this,
"o",
"FriendlyName" );
</script>

There is nothing specific to Adobe Analytics to consider - GTM has a built-in click event handler. Go to "triggers", "new", select "click" from the options and optionally specify filters (e.g. if you want the trigger to fire only on certain pages, or only when the link has a specific class).
Assign the trigger to a custom HTML tag with your Adobe Code, save, publish and you are all set.

Related

Is it possible to make GTM to tag some elements that are dynamically created

I'm a React developer and I barely knows how GTM works as it's not my field.
What I understand is
There are triggers on google tag manager
GTM script will find HTML elements of the triggers by defined css selectors(in my case) and tag them(put GTM attributes) when it's loaded in the page
When an event meeting the condition of a trigger occurs, the trigger will execute defined javascript(in my case)
The problem is that HTML elements possibly don't exist when GTM script is tagging because they can be created by a user interaction. And I want to tag such elements by using GTM's lifecycle method(if exists). Is there any way to do this or at least a workaround?
The best practice I can come up with is something like :
When you render the element you want to track in the React.
Let React push the datalayer about the information of the element like
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "element_render",
element_id: "#id",
element_type: "type",
any_paramter_you_need: "any_value_you_need",
})
So you can set up the Trigger in you Google Tag Manager and the type is Custom Event
Usually that should work out of the box. GTM does not tag elements directly. Instead, GTM is attached to the document root. If an element is clicked, the event bubbles up to the document root, and there GTM checks if the properties of the event target (the actually element interacted with) meet the conditions defined in the trigger.
So unless React is doing something super crazy with the document, you should be safe. Allowing to track dynamically added elements is pretty much the point of this design.
For visibility triggers, you specifically need to enable this behavior by clicking the checkbox on "observe DOM changes". There is a warning that this might impact page speed.

How can I prevent hammerspoon hotkeys from overriding hotkeys in other applications?

I'm looking at having a certain hotkey only available in Google Chrome:
hs.hotkey.bind({"cmd"}, "0", function()
if hs.window.focusedWindow():application():name() == 'Google Chrome' then
hs.eventtap.keyStrokes("000000000000000000")
end
end)
The issue with this approach is the hotkey will become un-usable on other apps. E.g. CMD+0 will not trigger the Reset Zoom command in Discord.
How can I prevent that?
The hs.hotkey API doesn't provide functionality to be able to propagate the captured keydown event. The hs.eventtap API does, but using it would involve watching for every keyDown event.
I'll point to what is mentioned in a somewhat related GitHub issue:
If you're wanting the key combo to do something for most applications, but not for a few specific ones, you're better off using a window filter or application watcher and enabling/disabling the hotkey(s) when the active application changes.
In other words, for what you're trying to achieve, it's recommended you use the hs.window.filter API to enable the hotkey binding when entering the application, and disable it when leaving the application, i.e. something like:
-- Create a new hotkey
local yourHotkey = hs.hotkey.new({ "cmd" }, "0", function()
hs.eventtap.keyStrokes("000000000000000000")
end)
-- Initialize a Google Chrome window filter
local GoogleChromeWF = hs.window.filter.new("Google Chrome")
-- Subscribe to when your Google Chrome window is focused and unfocused
GoogleChromeWF
:subscribe(hs.window.filter.windowFocused, function()
-- Enable hotkey in Google Chrome
yourHotkey:enable()
end)
:subscribe(hs.window.filter.windowUnfocused, function()
-- Disable hotkey when focusing out of Google Chrome
yourHotkey:disable()
end)

Angularitics (GA) add fixed value to all tracked events

I am using Angularitics (GA analytics) in my app.
Here's what I doing in my jade file.
a.btn(href="www.some.com" analytics-on="click" analytics-label={{UserID}} analytics-category="Some Category" analytics-event="Some Event")
Now I have a ton of these and the label is always UserId so i can track events by user.
Is there a simpler way to add a constant across the board value to all events. I have an angular app and want to add the userID for the logged in user to all events i track. Looking for a way to add that info without having to add it to each element i track in the html.
I would just recommend you using GTM instead.
With Angulartics and GTM, you can access the dataLayer directly with
window.dataLayer
So you can do something like this at the start of you controller or main app.
window.dataLayer.push('userId','example123');
Then in GTM just read that into a variable and push into GA with the userId as label for the event.

NetSuite / Suitescript - Focus on field on Page Load

Is there a way through workflow or suitescript to focus to a specific field when the page loads? I don't want a hack.
Thanks!
Unfortunately there is no way to access to the NetSuite UI using SuiteScript because it doesn't support direct access through the DOM. You need to use javascript.
You can use a client script to define the cursor location. In my example I use the field change but you should be able to apply the same logic to the pageinit.
function clientFieldChanged(type, name, linenum){
var nextElement = document.getElementsByName('inpt_custrecord_bathroom1_typeofbathroom');
nextElement[0].focus();
}

Trigger Google Analytics pageview for Angular App while using Google Tag Manager

I am building a SPA using Angular.js. We use Google Tag Manager to load in most of our analytics/marketing scripts, which includes Google Analytics. I am also using ui-router to manage states/views.
I would like to send pageview events off to Google Analytics whenever a user browses to a different state in my app. Part of the complexity in doing this with GTM is that GTM creates a named tracker. That means that all GA events need be prepended with the tracker name. That would usually look like this:
ga('trackerName.send', 'pageview', {page: '/a/path/', title: 'A Title'});
GTM uses a randomly generated tracker name, so the tracker name needs to be grabbed at runtime. That can be done fairly simply with GA's getAll function. If you want to send the pageview event to all trackers, you would simply do:
var allTrackers = ga.getAll();
for(var i=0; i<allTrackers.length; i++) {
ga.send(allTrackers[i].getName()+".send", "pageview", {page: '/a/path', title: 'A Title'});
}
This works great for most of my pageview events. However, there is a race condition between when ui-router fires the initial view's $stateChangeSuccess (which is where I trigger the GA pageview), and when analytics.js is loaded.
Prior to analytics.js being loaded, Google Analytic's snippet creates a faux ga object, that you can send events to. This faux object does not have the rest of the ga functions on it, so you can not run getAll. Without the getAll function, I cannot get the tracker name and I cannot send pageview events.
As far as I can tell, Google Analytics does not provide any callbacks or events for when analytics.js is finished loading, so there is no way to tell when I will be able to start sending events. Right now I am using an $interval to check for the existence of ga.getAll, but that is not a very performant or ideal solution. This is what I've got:
gaCheckInterval = setInterval(function() {
if(typeof(ga) !== 'undefined' && typeof(ga.getAll) == 'function') {
clearInterval(gaCheckInterval);
sendBackloggedEvents();
}
}, 200);
Is there any other way to recognize when analytics.js has finished loading? Or any other way to send events to a named tracker, without having access to getAll?
Attempting to configure and trigger individual trackers circumvents the purpose of using a tag manager. Instead do:
dataLayer.push({event:'spa.pageView', page:..., title:...});
Where:
dataLayer is optionally renamed in the gtm snippet
spa is a handy abbreviation for your app/project/company/whatever in case you need to distinguish its actions later.
page and title can be whatever you like, you will reference them by adding dataLayer macros in your GTM container.
Then, in the tag manager you configure:
rule of {{event}} ends with pageView.
dataLayer macros for the page, title you are pushing into the dataLayer.
UA Tag (and later whatever else) to fire (1) and use the macros in (2) for the TAG parameters they override.
Repeat (3) as many times as you like for different UA properties with additional blocking rules, alternate macros or more granular firing rules as necessary.
Now you can configure the specifics and add other tag types that reuse the rules and macros without modifying the application for each change.

Resources