Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wodenwang820118/nestjs-googlesheet-gtm
https://github.com/wodenwang820118/nestjs-googlesheet-gtm
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/wodenwang820118/nestjs-googlesheet-gtm
- Owner: WodenWang820118
- Created: 2022-09-21T07:12:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-29T08:10:55.000Z (about 2 years ago)
- Last Synced: 2023-03-08T19:06:53.873Z (over 1 year ago)
- Language: TypeScript
- Size: 169 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Objectives - Google Sheet x GTM
This is a prototype project to use Google sheet API to interact with GTM using GTM API, expect to:
- parse the specs and CRUD tags, events, and triggers to GTM
- parse the specs to check if tags, events, and triggers are correctly configured
- use pre-recorded Puppeteer scripts to automate the event triggering sequenceCurrently, the project is under development in two parts.
# Before running the code
## To use Google API
- in the Google cloud console, create a service account; invite the service account to the google sheet you want use
- add keys and, download the JSON file, rename it into `token.json` for authentication under the root folder
## To use GTM API
- in the Google cloud console, create a service account and enable GTM API; invite the account to GTM
- add keys and download the JSON file, rename it into `gtm_client_secrets.json` under the root folder
# Google Sheet API
- to use the API in the dev environment, please adda. `SPREADSHEET_ID`
b. `DATALAYER_TITLE`
c. `SHEET_NAME`
in a `.env` file.
The methodology looks for `DATALAYER_TITLE` in the given sheet and parses the valid specs as JSON syntax.Depending on the needs, you can modify the `google-sheet.service.ts` function to parse the google sheet cell string.
My Format
window.dataLayer.push({
"event" : "component_impression",
"site_category": "$site_category",
"component_name": "$component_name",
"position": "$position"
})# GTM API
According to GTM API, the format could be a lot of options, but I'll give an exampleThe format to create a tag
{
"name": "Event - Test Tag",
"type": "gaawe",
"parameter": [
{
"type": "boolean",
"key": "sendEcommerceData",
"value": ""
},
{
"type": "template",
"key": "eventName",
"value": ""
},
{
"type": "tagReference",
"key": "measurementId",
"value": ""
}],
"monitoringMetadata": {
"type": "map"
},
"consentSettings": {
"consentStatus": "notSet"
},
"firingTriggerId": [""]
}