google tag manager eCommerce - tags

I am getting crazy trying to get this to work.
I am pretty new to the whole Google Tag Manager thing, but after reading documentation, I got the basic google analytics to work.
Having said that, I am trying to set up an eCommerce transactions using dataLayer but I cannot seems to get it to work.
I am using the basic example taken on the main site:
var dataLayer = dataLayer || [];
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345',
'affiliation': 'Online Store',
'revenue': '35.43',
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': ''
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}]
}
}
});
In my GTM configuration, I have the following:
- Tag Type: Universal Analytics
- Track Type: Page View
- Google Analytics Settings: {{gaTrackingID}}
- Enable overriding settings in this tag: ticked
- Enable Enhanced Ecommerce Features: true
- Use Data Layer
and in the Trigger i have:
- Trigger Type: Page view
- Trigger fires on: "Page URL contains /checkout
I forgot to mention that I have two tags enabled, one to log activity on all pages and the second one which should log the purchase.
I can in google Analytics that the visit worked correcty, but the transaction does not.
Also, can someone tell me if the section "CONVERSATIONS -> Ecommerce" displays the standard or Enhanced Ecommerce?
I am a bit confused..
Why the above does not work?

I just found out this morning that the code actually worked, but google analytics takes around 24/48 hours to reflect the changes. this is something I did not read anywhere in most of the documentation I found. This kind of make the whole testing process a bit difficult, as the only thing we can do is to check if the event is fired (as far as I know).
Perhaps there is a better way (and more instant) to test whether an eCommerce data has been pushed to google Analytics?

Try to insert page and transaction information into a single 'ecommerce' object and not separated.
Regarding the data displayed in the ecommerce report in Analytics, it depends on whether you have enabled enhanced ecommerce settings or only those standard.

Related

Checkout.com not authorising specific transaction amounts

I have a strange issue where Checkout.com is working mostly fine, but if the transaction amount is a specific number it doesn't get authorised. In the screenshot below you can see the amount $101,234.62 never works, when trying two different cards, but any other amount (for the same cards) work.
I'm using the nodejs sdk in the following format:
const result= await cko.payments.request({
source: {
type:"id",
id: paymentMethodEntity.token,
},
currency: 'HKD',
amount: 10123462,
capture: false
});
I have sent an email to support which seems to be the only way to reach out (if there are other methods please let me know!), so I'm not sure how long they will take to get back to me. Any help appreciated.

How to connect to Actions builder project to update type entities?

I've got a project build migrated from AOG + Dialogflow to Actions Builder. I need to update (or insert new) type entries with the REST API.
To do that action I've found an endpoint, that gives the ability to update the whole project along with entities:
https://developers.google.com/assistant/actions/api/reference/rest/v2/projects.draft/write
However, I can't connect to that endpoint due to 401 error. Before that I've tried to emulate a similar request to another endpoint, which allows reading the project:
https://developers.google.com/assistant/actions/api/reference/rest/v2/projects.draft/read
Obviously, I've got the same error here.
Also, I've found this repo - https://github.com/actions-on-google/assistant-actions-nodejs
which adds a wrapper for easier manipulation with the REST API, but it also doesn't contain any information on how to properly authorize to get access to an app.
Can please somebody suggest how authorization should be done to start using this REST API?
Using Actions Builder, the type entities can be updated directly in your webhook calls rather than calling an API in parallel.
Look up the names of the types you want to override in Actions Builder and set the conv.session.typeOverrides field in your response.
Here's a code example of how it might be done:
const app = conversation()
// `app.middleware` will run on every invocation call
app.middleware(conv => {
// ...
// Obtain `trackTitles` and `trackGenres`
// ...
conv.session.typeOverrides = [{
name: 'track',
mode: Mode.TypeReplace,
synonym: {
entries: Array.from(trackTitles).map(title => ({
name: title,
synonyms: [title],
})),
},
}, {
name: 'genre',
mode: Mode.TypeReplace,
synonym: {
entries: Array.from(trackGenres).map(genre => ({
name: genre,
synonyms: [genre]
}))
}
}]
})

Custom Dimensions Not Reporting Through to Google Analytics API V4

I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,
You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()

Update Marketo lead's membership->progressionStatus using REST API

I'm trying to adapt https://github.com/Marketo/REST-Sample-Code/blob/master/php/LeadDatabase/Leads/SyncLeads.php for my own needs. I want to be able to update a lead's status from "Registered" to "Attended" using the REST API. (The Marketo Events app does this when someone is checked into an event.)
However, when I try sending something like:
{"input":[{"email":"asdfasdf#qwerqwer.org",
"membership":{"progressionStatus":"Attended"}}]}
I get back:
{"requestId":"168be#15868ee5bff",
"result":[{"status":"skipped","reasons":[
{"code":"1006","message":"Field 'membership' not found"}]}],
"success":true}
I understand the message just fine -- 'membership' isn't a field, therefore it can't be updated this way. But is there another way to update the progressionStatus using the API?
You need to be looking at that lead's membership of the program - see this method for more information: http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads/changeLeadProgramStatusUsingPOST
Try to use this format:
{
'status': 'Member',
'input': [
{'id': 23},
{'id': 445}
]
}
You have to use the Marketo Lead ID (not email) and you can only specify 1 status value per API call. Max batch size is 300 Lead IDs.

API design : Need help for URLs

I'm designing a new website. Before i start to code, i'm learning a lot about api and nosql database (as i'm used to sql but i want to try with mongoDB).
In mongoDB, i'll have a 'user' document like that :
{
firstname: 'xxxxxxx',
lastname: 'xxxxxxx',
projects: [
{
name: 'project xxxxxxx',
participants: [], // array of friends into this project
operations: [
{ title: 'Title OP xxxxxxx', contributors: [] },
{ title: 'Title OP xxxxxxx', contributors: [] },
{ title: 'Title OP xxxxxxx', contributors: [] }
]
}
]
}
I was wondering two things :
Should projects.participantsand projects.operations.contributors be references to other users ?
For the API, should i do something like :
GET /users/:id_user
GET /users/:id_user/projects/:id_project
GET /users/:id_user/projects/:id_project/operations/:id_operation
(should my API always start with users ?)
If you ever have a better solution I will be glad to know.
Thanks
EDIT 1 : I'll work on NodeJS with Express and i would like to have a REST API.
yes, projects.participants and projects.operations.contributors can be reference to other documents in the same collection. Each of these should refer to valid _id in the same collection.
can you please put some more light on how exactly are you creating your APIs? I mean which framework you are using as a wrapper to access mongoDB? May be then I can try to help more.
ok great!!!
So, users is your collection name. Its absolutely not necessary to start your API name with users. In node.js you can create a router, which will route your request to a particular js file and you can name it anything you want. Example:
use case: You want to expose 3 API
1. To access all the users. (exposed using url - /getallusers)
2. To access all the participants of the project.(exposed using url - /getparticipantsbyproject)
3. To access all the contributors in the operations.(exposed using url - /getcontributorsbyproject).
You can write all these APIs in your file called myapi and expose them.
Now, you can very well call these APIs from browser using below urls:
http://host:port/myapi/getallusers
http://host:port/myapi/getparticipantsbyproject
http://host:port/myapi/getcontributorsbyproject
Its about RESTful API only. I mentioned 3 urls above which are nothing but RESTful API exposing different functionalities.