-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New snippets. #14
Open
arycaramez
wants to merge
7
commits into
lucianfialho:main
Choose a base branch
from
arycaramez:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New snippets. #14
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e2eee81
New addition convert snippet Woo Commerce Items to GA4 Items
arycaramez 70d501b
Convert Vtex orderPlaced event to GA4 purchase event format
arycaramez a5f61ca
Change in the name of the script from 'convertVtexIoPurchaseItemsToGA…
arycaramez a57b4e3
Adjustment made to the snippet name
arycaramez f35efc4
Merge branch 'lucianfialho:main' into main
arycaramez 2d9894c
Exemplo adicionado exemplos nos snippets que adicionei
arycaramez 6286a92
Merge branch 'main' of https://github.com/arycaramez/30-seconds-gtm
arycaramez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Convert a list of products from the Vtex `orderPlaced` event into the format recommended for Google Analytics 4 (GA4) using a custom JavaScript function in Google Tag Manager. In Vtex, the `orderPlaced` event is utilized instead of `purchase`. The provided code snippet facilitates the conversion of the `orderPlaced` event model to the `purchase` model recommended by GA4. It processes the products array within the ecommerce object, which is part of the `orderPlaced` event in Vtex. The function maps each product to a new format that aligns with GA4's e-commerce data model requirements, ensuring compatibility with GA4's enhanced e-commerce tracking features. | ||
|
||
> You must create the variable `{{ecommerceV2}}` in Google Tag Manager to capture the object containing transaction data in the `orderPlaced` event. | ||
|
||
- Return `items` list with a recomended GA4 pattern. | ||
|
||
* Remember to check if the event parameters match the structure we prepared. Parameters may change over time. | ||
|
||
```js | ||
function () { | ||
return {{ecommerceV2}}.ecommerce.purchase.products.map(function(item){ | ||
return { | ||
'item_id': item.id.toString(), | ||
'item_name': item.name, | ||
'currency': item.currency || 'BRL', | ||
'item_brand': item.brand, | ||
'item_category': item.item_category || item.category, | ||
'price': parseFloat(item.price), | ||
'quantity': parseInt(item.quantity) || 1 | ||
} | ||
}) | ||
} | ||
``` | ||
|
||
```js | ||
/* | ||
[ | ||
{ | ||
"item_id": "101", | ||
"item_name": "Sneakers", | ||
"currency": "USD", | ||
"item_brand": "BrandA", | ||
"item_category": "Footwear", | ||
"price": 59.99, | ||
"quantity": 1 | ||
} | ||
] | ||
*/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Convert a list of items from a `WooCommerce` event into the recommended format for `Google Analytics 4 (GA4)` using a custom JavaScript function in `Google Tag Manager`. The provided code snippet processes the `items` array, which originates from an `ecommerce` event, mapping each item to a new format that aligns with `GA4's e-commerce data model` requirements. This transformation ensures compatibility with `GA4's enhanced e-commerce` tracking features. | ||
|
||
> You have must be created `{{ecommerce}}` dataLayer variable on Google Tag Manager. | ||
|
||
- Return `items` list with a recomended GA4 pattern. | ||
|
||
* Remember to check if the event parameters match the structure we prepared. Parameters may change due to WooCommerce updates. | ||
|
||
```js | ||
function() { | ||
return {{ecommerce}}.items.map(function(item) { | ||
return { | ||
item_id: item.item_id.toString(), | ||
price: parseFloat(item.price), | ||
quantity: parseInt(item.quantity) || 1, | ||
item_name: item.item_name, | ||
item_variant: item.item_variant || item.variant, | ||
item_category: item.item_category | ||
}; | ||
}); | ||
} | ||
``` | ||
|
||
```js | ||
/* output: | ||
{ | ||
"items": [ | ||
{ | ||
"item_id": "001", | ||
"price": "19.99", | ||
"quantity": "2", | ||
"item_name": "Graphic Tee", | ||
"item_variant": "Medium", | ||
"item_category": "T-shirts" | ||
}, | ||
{ | ||
"item_id": "002", | ||
"price": "29.99", | ||
"quantity": "1", | ||
"item_name": "Hoodie", | ||
"item_variant": "Large", | ||
"item_category": "Outerwear" | ||
} | ||
] | ||
} | ||
*/ | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coloca um exemplo do input antes do script pra mim?