Are Google Ads API order_id and Google Ads GTM Tag transaction_id the same? - google-tag-manager

I'm planning to implement the Google Ads API uploadClickConversions functionality allongside the already working dataLayer implementation. We use transaction_id in the dataLayer for deduplication.
In the uploadClickConversions API we will add the order_id. Since these names are not consistent I'm not entirely sure if orders which are submitted both trough the API and the GTM tag will be deduplicated properly.
The only hint of this being the case is a comment in this example code: https://developers.google.com/google-ads/api/docs/samples/upload-conversion-with-identifiers
* #param string|null $orderId the unique order ID (transaction ID) of the conversion
But this information is a bit to flimsy for me to assume it will work out alright.

Related

Retrieving user_pseudo_id from GA4 api

Is there a way to retrieve the user_pseudo_id field from GA4 api? It is not present in the dimensions list of the documentation but neither was the clientId for UA although it could be specified as a dimension.
See reference for clientID parameter in the older GA-UA APIs.
I need to retrieve historical data from GA4 and import them into Google BigQuery but not all export's fields are present in the GA4 api.
You will need to pass it as a custom user parameter via Google Tag Manager. Just need to set it once and then the rest of your GA4 tags will inherit it. Here’s a pretty good tutorial on how to do this: https://www.simoahava.com/gtmtips/write-client-id-other-gtag-fields-datalayer/

Send User ID from Google Tag Manager to Google Analytics 4

I have set up google tag manager with my GA4 property
(NOT legacy Universal Analytics)
according to the official guide:
https://support.google.com/tagmanager/answer/6103696?hl=en&ref_topic=3441530#zippy=%2Cweb-pages
and I have figured out how to send custom/recommended events to GA4 using
dataLayer.push({}) objects, using their "event" field in triggers and tags,
based on a Universal Analytics guide
(https://www.analyticsmania.com/post/track-logins-with-google-tag-manager/),
because this appears to be a black hole in the official guide:
https://support.google.com/tagmanager/answer/9442095
only describes, briefly, the GTM-side of the story.
Same goes for sending User ID: the docs only tell
when creating a Google Analytics 4 Configuration tag:
To set a user ID, add a row to Fields to Set.
Set the Field Name to user_id, and the Value to
a Tag Manager Variable that returns the user ID.
and I only take the knowledge from the external UA guides
to use a Data Layer Variable that reads the user_id field from the dataLayer,
and also create a corresponding user_id User Property on Google Analytics,
which in Universal Analytics used to
have related settings that don't exist anymore
(https://www.analyticsmania.com/post/google-analytics-user-id-with-google-tag-manager/).
So I have deployed my GA4 Events with the user_id data layer variable
referenced in their Configuration (and it is visible on the datalayer in Debug View),
created the corresponding User Property in GA, and enabled User-ID reporting.
Yet, in my real-time view, the user_id fields always get some weird "gtm.js" value
(as if my data layer variable value was replaced by the event name
from the default dataLayer.push({event:"gtm.js",user_id:"ignored value")).
What in the world is missing for my user_id field to be recognised?
Thanks!
Thanks #bpstrngr! Was going around in circles for a while before finding your answer.
To clarify the step by step in case anyone else bumps into this;
When sending userId in dataLayer add an event name:
window.dataLayer.push({
'userId' : '{{ myUserId }}',
'event': 'userIdSet',
})
In GTM, create a Custom Event trigger that listens to that event (set event name equal to whatever event you wrote in step 1):
Add this event as a firing trigger into your tag:
So at long last it turned out,
that since the configuration tag was fired by the Page View event,
that happened before I pushed the user_id to the dataLayer,
so it filled the non-existing value with the event name instead.
I gave the user_id event a name to create a custom event trigger,
that re-triggers the configuration tag.
This way the user_id-s are finally visible.

add transaction manually to Google Analytics and eCommerce

I'm using the following tutorial, http://www.lunametrics.com/blog/2014/03/04/tracking-offline-transactions-universal-analytics/ which tells us how to add a transaction manually using a url like the following:
http://www.google-analytics.com/collect?v=1&tid=UA-123456789-1&cid=75839030.509493873&t=transaction&ti=52ea5aab1f0c2&tr=1100&cd1=52ea5a8bc6a4a
This works ok. However, the eCommerce part of GA does not register a conversion, so it's not possible to use the multi channel funnels report.
I'm wondering is there a way to register a sale similar to how a shopping cart would on a webpage? Would I have to add in the "clientId" for the customer, into the cart so the sale can be recorded against all the other actions in GA?
OR am I doing something wrong? Such as not registering an item? Would this trigger the ecommerce conversion to register?
Either way, somehow the ecommerce tag is not firing, so I can't record multi channel funnels based on clientId
You need save clientId in custom dimensions and in your site (it can be hide field, for example)
If you send transaction with use real clientid (send cid and cd# parameters) = this transaction will be linked with this user and all actions with this cid
On my practice better send t=event&ec=ecommerce&ea=purchase&pa=purchse&item...
With this method I have all data in ecommerce reports

How can I link my customers with ganalytics visitor

Most of my website traffic come from adwords, and fill a form to get called.
When A user fill a form, I have a customer created on my database.
For my business strategy, I want to know how much I payed for that lead, and how much benefit I make with it after the call.
For that I think I have to link analytics visitors and my customers directly.
I am searching for a way to put an analytics visitor ID on the request form or something like this...
You would need to get the visitor id and pass it into either a custom variable (ga.js) or custom dimension (analytics.js).
To get the visitor id for Google Analytics (ga.js) *I got this code from How to obtain Google Analytics visitor unique id? SO Answer:
_gaq.push(function(){
var tracker = _gat._getTrackers()[0];
var visit_code = tracker._visitCode();
console.log(visit_code);
});
To get the visitor id for Universal Analytics (analytics.js) *More documentation on this in Google's documentation:
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
I've used this before, too:
ga.getAll()[0].get('clientId');
The best strategy in your case is:
Get user ID from GA or UA(as desribed advisor above)
Send user ID to database
Set up user ID as custom variable(in Googl Analytics) or custom dimension(in Universal Analytics)
Set up custom reports, where you can segment your visitors by their ID's

how to customize Tracking Ecommerce Transactions with Google Analytics?

In the Ecommerce Transactions with Google Analytics, we can code as below:
_gaq.push(['_addTrans',
'1234', // order ID
'SitePoint', // store
'19.99', // total
'1.50', // tax
'3.00', // shipping
'Chicago', // city
'Illinois', // state
'USA' // country
]);
But I want to implement it for employer registration page where I wont get order_id and total fields. Instead can I use employer_id and company name by replacing oerder_id and store...
Will it works ?
for reference you can see GA Ecommerce
How to use it for employer registration ?
You can do that but it may not be the best way to do it. If I were going to do it this way I'd use some code to generate a dummy transaction id and then set the total fields to $1. Here is some code to generate an order_id:
function generateOrderId() {
// really crude unique ID
var d = new Date();
var r = Math.floor(Math.random()*1000);
return d.valueOf()+''+r;
}
A better way to do this is to track it with events. These are designed for tracking special things that don't have a dollar amount directly associated. For example, downloads, or the number of times a person clicks play on a video player.
The docs are pretty good and if you understand that Sitepoint article the event tracking won't be hard. (it's actually a simpler process than ecommerce)
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

Resources