This is the code being sent from our confirmation page for GA universal using enhanced ecommerce:
ga("create", "UA-XXXXXXX-xx", "auto");
ga("require", "displayfeatures");
ga("require", "ec");
ga("ec:addProduct", {
Id: null,
Name: "ProductNameTest",
Brand: "Foo",
Category: null,
Variant: null,
Price: 5.49,
Quantity: 1,
Coupon: "",
Position: 0
});
ga("ec:setAction", "purchase", {
Id: "33558",
Affiliation: "Foo",
Revenue: 5.49,
Tax: 0,
Shipping: 0,
Coupon: "",
List: null,
Step: 4,
Option: null
});
ga("send", "pageview");
I'm not seeing any issues in the GA debugger or in the Tag Assistant plugin for Chrome.
What am I missing here that our conversion data/transactions aren't showing up?
EDIT:
Here is the output from the GA debugger that I stripped for the above:
Initializing Google Analytics.
Loading resource for plugin: ec
Loading script: "http://www.google-analytics.com/plugins/ua/ec.js"
Running command: ga("create", "UA-XXXXXXX-xx", "auto")
Creating new tracker: t0
Running command: ga("require", "displayfeatures")
Set called on unknown field: "dcLoaded".
Plugin "displayfeatures" intialized on tracker "t0".
Running command: ga("require", "ec")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Registered new plugin: ga(provide, "ec", Function)
Running command: ga("require", "ec")
Plugin "ec" intialized on tracker "t0".
Running command: ga("send", "pageview")
I see a few issues that could be affecting your transactions:
Duplicate ga("require", "ec") commands.
Id for addProduct is null. This is a required value, and should be a string.
More of a javascript best practice: after you've invoked your function, end it with a semicolon. e.g. ga("send", "pageview");
EDIT:
Regarding point #2, the Id for addProduct CAN be null, if the developer is passing a value for the name parameter instead (see Product Data table).
All property key's must be lowercase i.e. Id should be id. (Thanks for Eduardo for pointing out).
Related
We're trying to configure GA4 to gather same data that we have in UA.
The problem is that we cant see custom metrics data on item-level in DebugView.
In TagAssistant we can see that data is sent:
{
event: "purchase",
gtm: {uniqueEventId: 10, start: 1651XXX},
gtag: {
targets: {
G-XXX: {_ee: true, _uei: 3, _upi: 2},
UA-XXX: {
currency: "PLN",
country: "PL",
custom_map: {
dimension2: "referrer",
...
dimension13: "ecomm_totalvalue",
metric1: "metric1",
...
metric5: "metric5"
},
_uei: 4
},
AW-106XXX: {}
}
},
eventModel: {
transaction_id: "40XXX",
affiliation: "XXX",
value: "9.99",
currency: "PLN",
tax: "1.87",
shipping: "0",
coupon: "",
items: [
{
id: "670",
name: "Tusz Zamiennik T0711 do Epson (C13T07114010) (Czarny)",
brand: "XXX",
category: "Wkłady/Atramentowe/Zamienniki/Tusze/XXX -> Do:E" +
"pson",
quantity: 1,
price: "9.99",
coupon: "",
metric1: "9.99",
metric2: "9.99",
metric3: "9.99",
metric4: "9.99",
metric5: "9.99"
}
],
send_to: ""
}
}
However, on DebugView side we can see purchase event that:
contains all orginal parameters on event level (like transaction_id, shipping etc.)
contains all orginal parameters on item level (like item_id, quantity, etc.)
But our custom metrics are missing
In the other hand, we tried (with different event) push some custom-dumension data and:
they are visible on GA4 DebugView
we can create custom dimension in GA4 basing on this data and it works
I am thinking about:
Creating event-level custom metric to test if it will be passed to GA4 DebugView
Creating item-level custom dimension to test if it will be passed to GA4 DebugView
However, due to fact that GA requires 24h to make conclusions i decided to ask here for any sugestions why it is not working and what else may i test.
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `#gatsbyjs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
{
resolve: "gatsby-source-graphql",
options: {
// Arbitrary name for the remote schema Query type
typeName: "DRUPAL",
// Field under which the remote schema will be accessible. You'll use this in your Gatsby query
fieldName: "drupal",
// Url to query from
url: "https://intl-pgs-rsm-growth-platform.pantheonsite.io/graphql",
},
},
],
}
Here's my gatsby-config.js file
When I run gatsby clean && gatsby develop or just gatsby build i get
success createSchemaCustomization - 0.005s
ERROR #11321 PLUGIN
"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:
Unexpected token < in JSON at position 0
ServerParseError: Unexpected token < in JSON at position 0
- JSON.parse
- index.js:35
[test-gatsby]/[apollo-link-http-common]/lib/index.js:35:25
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
not finished source and transform nodes - 0.506s
My Drupal 8 site is new with the graphql module installed. And the gatsby site is brand new too.
I started getting this issue on Monday after working fine for a while. There were no code changes to my gatsby but all of a sudden I'm no longer able to get drupal data.
There seems to be few examples of using the "gatsby-source-graphql" plugin so if anyone can help please do
In my case, it was a permissions issue in Drupal. I solved it by going to admin → people → permissions and setting all permissions related to GraphQL for the anonymous user.
The Drupal Graph QL Module requires authentication using tokens. You can use Simple Oauth or JWT. I used Simple Oauth and resolved my issue using the following steps:
Install the Simple Oauth module using composer so it installs it's dependancies $ composer require drupal/simple_oauth, then enable the module.
Create a user role for your third party app and assign content viewing permissions for that role
In admin/config/people/simple_oauth add a token expiration time, generate keys using the button provided (make sure they are generated outside of the drupal web root) and add the path to the public and private key files.
In admin/config/services/consumer add a new consumer (or use the default consumer)
Add a secret password in the Secret field and select the new role you created under Scopes, then save the config page.
Make a post request to your site https://intl-pgs-rsm-growth-platform.pantheonsite.io/oauth/token using curl or postman to generate a token using the following body fields:
grant_type: password
client_id: The client id generated `admin/config/services/consumer`
client_secret: The secret you entered in step 4
username: A user in your drupal site that has the role you created
password: The password assigned to that account
The post request should return the access token if successful. Add your token to your app's .env.development file and update your gatsby-config.js file with the Authorization header: (More info about setting up environment variables in your gatsby app can be found here)
{
resolve: "gatsby-source-graphql",
options: {
typeName: "DRUPAL",
fieldName: "drupal",
url: "https://intl-pgs-rsm-growth-platform.pantheonsite.io/graphql",
headers: {
"Authorization": `Bearer ${process.env.GATSBY_API_TOKEN}`
},
},
},
Video Tutorials of the Simple Oauth set up steps can be found here
More information on this set up process can be found here
I'm pushing some tags to the data layer and they all seem to be working as expected except for ecommerce transaction data. I have confirmed that the transaction data is being pushed to the data layer but for some reason I'm not seeing any results in Google Analytics—even after waiting 48 hours.
I should mention that this is an SPA so there is no page refreshing. The data is pushed to the data layer after the payment is successfully processed.
This is the data I'm sending:
{
event: 'subscribe',
user: <USER_ID>,
subscribe: {
transactionId: <CUSTOMER>,
transactionAffiliation: <AFFILIATION>,
transactionTotal: <PRICE>,
transactionProducts: [
{
id: <CUSTOMER>,
sku: <SUBSCRIPTION>,
name: <PLAN>,
price: <PRICEPER>,
quantity: <QUANTITY>
}
]
}
};
Is there something wrong with the way I'm formatting this? Any ideas why this doesn't seem to be working?
For just regular NOT enchanced ecomm, you need to make some adjustments to your datalayer first:
{
event: 'subscribe',
user: <USER_ID>,
transactionId: <CUSTOMER>,
transactionAffiliation: <AFFILIATION>,
transactionTotal: <PRICE>,
transactionProducts: [{
id: <CUSTOMER>,
sku: <SUBSCRIPTION>,
name: <PLAN>,
price: <PRICEPER>,
quantity: <QUANTITY>
}]
};
Then create a custom event trigger referencing the subscribe event:
Then create a GA tag and select Track Type of Transaction, elect your GA settings variable and set the trigger to that custom event trigger we created above:
Ater googling for an hour or 2 I give up. While executing the code below, this is the result of the Chrome Google Analytics plugin. I have activated Ecommerce in the GA-admin settings for this ID. Pagevies are executed perfectly and visible using ga('send', 'pageview') but a purchase action fails...
analytics_debug.js:10 Initializing Google Analytics.
analytics_debug.js:10 Loading resource for plugin: ec
analytics_debug.js:10 Loading script: "http://www.google-analytics.com/plugins/ua/ec.js"
analytics_debug.js:10 Running command: ga("create", "UA-23554312-1", "auto")
analytics_debug.js:10 Creating new tracker: t0
analytics_debug.js:10 Auto cookieDomain found: "none"
analytics_debug.js:10 Running command: ga("require", "ec")
analytics_debug.js:10 Waiting on require of "ec" to be fulfilled.
analytics_debug.js:10 Registered new plugin: ga(provide, "render", Function)
analytics_debug.js:10 Running command: ga("require", "ec")
analytics_debug.js:10 Waiting on require of "ec" to be fulfilled.
analytics_debug.js:10 Executing Google Analytics commands.
analytics_debug.js:10 Registered new plugin: ga(provide, "ec", Function)
analytics_debug.js:10 Running command: ga("require", "ec")
analytics_debug.js:10 Plugin "ec" intialized on tracker "t0".
analytics_debug.js:10 Running command: ga("ec.setAction", "purchase", {id: "362", affiliation: "Besteld winkel Barendrecht", revenue: "2.95", shipping: "0", tax: "0.17"})
analytics_debug.js:10 Command ignored. Unknown target: undefined
I really do not know what is wrong with this code and it ends with 'unknown target'. Does anybody have a clue what I am missing here?
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-23554312-1', 'auto');
ga('require', 'ec');
ga('ec.setAction', 'purchase', {
'id': '362',
'affiliation': 'Besteld winkel Barendrecht',
'revenue': '2.95',
'shipping': '0',
'tax': '0.17'
});
</script>
Thanx for your time,
Regards, Marc Verkade
This looks like a straightforward syntax error.
Change ec.setAction to ec:setAction and you should be OK.
I have implemented Google Analytics with multiple trackers using this url : https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers#working_with_multiple_trackers
Then have tried to implement enhanced ecommerce in it,But the product categories are not being tracked.In analytics panel , it is showing (not set). I don't know where i went wrong since am not a SEO Expert.
In header :
<script>
//Google Analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-123', 'auto');
ga('create', 'UA-456', 'auto', 'abc');
ga('create', 'UA-789', 'auto', 'xyz');
//Ecommerce tracking code
ga("require", "ec", "ec.js");
//Ecommerce tracking code
</script>
In Product Listing,where all products of same category can be viewed
<script type="text/javascript">
ga('ec:addImpression', {
'id': '<?php echo $sku_idx; ?>', // Product details are provided in an impressionFieldObject.
'name': '<?php echo $curr_product['disp_name'];?>',
'category': '<?php echo check_product_brand($curr_product['category'],$curr_product['L2']).'/'.ucfirst($curr_product['category']);?>',
'brand': '<?php echo $curr_product['style'];?>',
'variant': '<?php echo $attr_code?>',
'list': 'Product Listing',
//'position': 1 // 'position' indicates the product position in the list.
});
At the end
<script type="text/javascript">
ga('send', 'pageview');
ga('abc.send', 'pageview');
ga('xyz.send', 'pageview');
Here is the console :
Initializing Google Analytics.
Loading resource for plugin: ec
Loading script: "https://www.google-analytics.com/plugins/ua/ec.js"
Running command: ga("create", "UA-123", "auto")
Creating new tracker: t0
Auto cookieDomain found: "mytest.com"
Running command: ga("create", "UA-456", "auto", "abc")
Creating new tracker: dieselitaly
Auto cookieDomain found: "mytest.com"
Running command: ga("create", "UA-789", "auto", "xyz")
Creating new tracker: syg
Auto cookieDomain found: "mytest.com"
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Registered new plugin: ga(provide, "render", Function)
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Running command: ga("require", "ec", "ec.js")
Waiting on require of "ec" to be fulfilled.
Executing Google Analytics commands.
Registered new plugin: ga(provide, "ec", Function)
Running command: ga("require", "ec", "ec.js")
Plugin "ec" intialized on tracker "t0".
Running command: ga("ec:addImpression", {id: "98263", name: "Ab - Jacket", category: "Apparel/Men/Jackets", brand: "123456", variant: "900", list: "Product Listing"})
Running command: ga("ec:addImpression", {id: "98263", name: "Ab - Jacket", category: "Apparel/Men/Jackets", brand: "123456", variant: "900", list: "Product Listing"})
Executing Google Analytics commands.
Running command: ga("send", "pageview")
Sent beacon:
v=1&_v=j44d&a=1234658035&t=pageview&_s=1&dl=https%3A%2F%2Fmytest.com%2Fproduct%2Fmens%2Fjackets&ul=en-us&de=UTF-/...... some stuff here
_j1 (&jid)
adSenseId (&a) 1234658035
apiVersion (&v) 1
clientId (&cid) 819866210.1464779007
ec:impression list "1" name (&il1nm) Product Listing
ec:impression list "1" product "1" brand (&il1pi1br) 123456
ec:impression list "1" product "1" category (&il1pi1ca) Apparel/Men/Jackets
ec:impression list "1" product "1" id (&il1pi1id) 98263
ec:impression list "1" product "1" name (&il1pi1nm) Ab - Jacket
ec:impression list "1" product "1" variant (&il1pi1va) 900
encoding (&de) UTF-8
flashVersion (&fl) 22.0 r0
hitType (&t) pageview
javaEnabled (&je) 0
language (&ul) en-us
location (&dl) https://mytest.com/product/mens/jackets
screenColors (&sd) 24-bit
screenResolution (&sr) 1366x768
title (&dt) Online Store: jeans, clothing, shoes, bags and watches
trackingId (&tid) UA-123
viewportSize (&vp) 1349x291
Executing Google Analytics commands.
Running command: ga("abc.send", "pageview")
Sent beacon:
v=1&_v=j44d&a=1234658035&t=pageview&_s=1&dl=https%3A%2F%2F Some stuff here
_j1 (&jid)
adSenseId (&a) 1234658035
apiVersion (&v) 1
clientId (&cid) 819866210.1464779007
.
.
.
Executing Google Analytics commands.
Running command: ga("xyz.send", "pageview")
Sent beacon:
v=1&_v=j44d&a=1234658035&t=pageview&_s=1&dl=https%3A%2F%2Fau Again some stuff
_j1 (&jid)
adSenseId (&a) 1234658035
apiVersion (&v) 1
clientId (&cid) 819866210.1464779007
Sorry for pasting such a large console.
I console i can see all the impression data being sent to only one tracking account.Is other 2 tracking accounts getting the data ?
When tracking enhanced ecommerce with multiple trackers, you need to include the tracker name and basically replicate all ecommerce calls for the specific tracker, for example:
ga('require', 'ec', 'ec.js'); // unnamed tracker
ga('abc.require', 'ec', 'ec.js'); // abc tracker
ga('xyz.require', 'ec', 'ec.js'); // xyz tracker
// ...
ga('ec:addImpression', .....); // unnamed tracker
ga('abc.ec:addImpression', ......); // abc tracker
ga('xyz.ec:addImpression', ......); // xyz tracker
// ...
ga('send', 'pageview'); // unnamed tracker
ga('abc.send', 'pageview'); // abc tracker
ga('xyz.send', 'pageview'); // xyz tracker
you have parameter 'Product category', it is wrong
use name 'category'