How to send event parameters for a tag through the google tag manager API - google-analytics

With this query i can create a GTM event tag for Google Analytics 4. i would like to pass some event parameters aswell. I feel that im really close because the API seems to recognize the eventParameters key, it tells me that its value its invalid.
"vendorTemplate.parameter.eventParameters[0]: The value is invalid.\n",
If i change this eventParameters key to something else, the query goes through (obviously without taking into consideration my eventParameters) so i know that this code has to be close.
The documentation is really shallow so building queries with the GTM api its been very trial and error until now.
When i get this working i'll probably make a sample for automating trigger and tag creation for GA4 migrations
`
{
"name": "test2",
"type": "gaawe",
"parameter": [
{
"type": "template",
"key": "eventName",
"value": "hey"
},
{
"type": "tagReference",
"value": "LocalTag",
"key": "measurementId"
},
{
"type": "list",
"key": "eventParameters",
"list": [
{
"type": "template",
"value": "page_title",
"key": "page_title"
}
]
}
]
}
`

The parameters is a array
Here is the example:
{
"type": "MAP",
"map": [
{
"type": "TEMPLATE",
"key": "name",
"value": `${parameterName}`
},
{
"type": "TEMPLATE",
"key": "value",
"value": `${parameterValue}`
}
]
}
And if you want to pass a variable to the value
Just add the "{{" , "}}" as you used in GTM UI.
Like {{DataLayer-Ecommerce}}
So yes you are very close to it.

Related

Azure ARM and SQL Database size

Here is the portion of my ARM file about the database:
{
"type": "Microsoft.Sql/servers/databases",
"name": "[concat(variables('SqlServerName'), '/', variables('dbName'))]",
"tags": {
"displayName": "Database"
},
"location": "[resourceGroup().location]",
"apiVersion": "2020-02-02-preview",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', variables('SqlServerName'))]"
],
"properties": {
"collation": "[parameters('dbCollation')]",
"edition": "[parameters('dbEdition')]",
"maxSizeBytes": "53687091200",
"requestedServiceObjectiveName": "[parameters('dbRequestedServiceObjectiveName')]"
}
}
And here my parameters:
"dbEdition": {
"value": "Standard"
},
"dbRequestedServiceObjectiveName": {
"value": "S2"
}
But these database properties are ignored and the deployed database doesn't respect them.
What's wrong?
UPDATE
As #SwathiDhanwada pointed out in comments, the edition property may not exist as per the doc.
I should use sku defined like:
Yet the powershell script to get a list of available skus for a given location returns something like:
The headers of the table are not the same as the properties of the sku object 🤦‍♂️

Put Azure Key Vault value in parameter array

I am trying to deploy a App service webapp via ARM template and need to put a secret from a key vault into an app setting (env variable).
I have always simply used an array of values from a parameters file to populate these app settings, but now I am struggling to get a keyvault value into that array. Something like shown below in an ARM parameter file.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"someStringParam": {
"value": "stringLiteralValueHere"
},
"envVars": {
"value": [
{
"name": "envVarKeyName",
"value": "stringLiteralValueHere"
},
{
"name": "KVsecret1",
"value": ##KEY VAULT SECRET HERE##
}
]
}
}
}
I have tried using a reference to the keyvault for the value but that errors on deployment.
{
"name": "KVsecret1",
"reference": {
"keyVault": {
"id": "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.KeyVault/vaults/<vault_name>"
},
"secretName": "secret1"
}
}
I have also tried using a parameter inside of the parameter file, but that just used the literal string for the value.
"parameters": {
"KVsecret1": {
"reference": {
"keyVault": {
"id": "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.KeyVault/vaults/<vault_name>"
},
"secretName": "KVsecret1"
}
},
"envVars": {
"value": [
{
"name": "envVarKeyName",
"value": "stringLiteralValueHere"
},
{
"name": "KVsecret1",
"value": "[parameters('KVsecret1')]"
}
]
}
}
Is this possible??
EDIT: Adding some detail here.
I am also trying to shoe horn a reference to another resource to get put the app insights instrumentation key into an app setting. Below is what I would like to do, but the copy function needs to use the name of the property and that is dynamic in this case as it changes with the each member of the array from the parameter file.
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2022-03-01",
"name": "[concat(parameters('backEndwebAppName'),'/appsettings')]",
"kind": "string",
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(concat('microsoft.insights/components/',parameters('appInsightsName')),'2020-02-02').InstrumentationKey]",
"secret1FromKeyvault": "[parameters('secret1FromKeyvault')]",
"copy": [
{
"name": "envVarsFromParams",
"count": "[length(parameters('backEndEnvVariables'))]",
"input": {
"name": "[parameters('backEndEnvVariables')[copyIndex('envVarsFromParams').name]]",
"value": "[parameters('backEndEnvVariables')[copyIndex('envVarsFromParams').value]]"
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('backEndwebAppName'))]"
]
},
This isn't possible today within the param file, but in your scenario (if it's as simple as your OP example) you can just union the two in your template. So in your parameter file, you have 2 params kvSecret (the reference) and envVars (all your other env vars) and then in the template use:
"variables": {
"keySecretObj": {
"name": "kvSecret",
"value": "[parameters('kvSecret')]"
},
"envVarsFinal": "[union(parameters(variables('kvSecretObj`), parameters(`envVars`))]"
That help?

Cleaning a GTM Template

We are currently using a GTM template provided by an advertising firm. We intend to no longer use this firm but would like to keep the same tags in place. We don't want our data being sent back to them as a result of the GTM template. I have taken out any sensitive information but would like to know which values to remove or change.
The Template URL under Add to Cart would obviously need to be changed but what about container id or path? Are these just informational concerning the account that exported this file or does this pass data back to their account? The specified tagManagerUrl does not match my account.
Anything else to look out for? I have attached a small segment of the file.
Thank you
{
"exportFormatVersion": 2,
"exportTime": "2019-01-10 11:11:11",
"containerVersion": {
"path": "accounts/XXX/containers/XXX/versions/0",
"accountId": "XXX",
"containerId": "XXX",
"containerVersionId": "0",
"container": {
"path": "accounts/XXX/containers/XXX",
"accountId": "XXX",
"containerId": "XXX",
"name": "the Container",
"publicId": "GTM-XXX",
"usageContext": [
"WEB"
],
"fingerprint": "XXX",
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/XXX/containers/XXX/workspaces?apiLink=container"
},
"tag": [
{
"accountId": "XXX",
"containerId": "XXX",
"tagId": "10",
"name": "Add Item to Cart",
"type": "img",
"parameter": [
{
"type": "BOOLEAN",
"key": "useCacheBuster",
"value": "true"
},
{
"type": "TEMPLATE",
"key": "url",
"value": "https://AdVendorURL/xxx/item?&XXX"
},
{
"type": "TEMPLATE",
"key": "cacheBusterQueryParam",
"value": "gtmcb"
}
],
"fingerprint": "XXX",
"firingTriggerId": [
"7"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
}
},
I would not remove anything from the template. In your Google Tag Manager container go to Admin > Import Container and follow the instructions to import the configuration. Once you have complete go to your Workspace and select Tags from the menu. Locate the tag Add Item to Cart and remove it.

How to handle large inputs into the Text Translator Api?

I am working on a cognitive skillset in Azure Search, and I need to add Text Translator functionality to the project. Currently all of the text is translated correctly, unless the character count is above the maximum value. In which case, the api returns null.
I am currently using document/content as my input for the text translator, but I've also tried using the output of the predefined Split Skill. When I pass the files through the Split Skill (by page) before the translator skill, the indexer breaks and all of the files fail to index (even the ones that don't need to be translated)
This code taken from my skillset.json that translates all of the files below the character limit cutoff.
{
"#odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
"description": "Our new translator custom skill",
"uri": "[my-uri]",
"batchSize":1,
"context": "/document",
"inputs": [
{
"name": "text",
"source": "/document/content"
},
{
"name": "language",
"source": "/document/languageCode"
}
],
"outputs": [
{
"name": "text",
"targetName": "translatedText"
}
]
}
This is my attempt to split the text by page before passing the text through the translator api. This results in a 501 error.
{
"#odata.type": "#Microsoft.Skills.Text.SplitSkill",
"textSplitMode" : "pages",
"maximumPageLength": 4000,
"inputs": [
{
"name": "text",
"source": "/document/content"
},
{
"name": "languageCode",
"source": "/document/languageCode"
}
],
"outputs": [
{
"name": "textItems",
"targetName": "pages"
}
]
},
{
"#odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
"description": "Our new translator custom skill",
"uri": "[my-uri]",
"batchSize":1,
"context": "/document/pages/*",
"inputs": [
{
"name": "text",
"source": "/document/pages/*"
},
{
"name": "language",
"source": "/document/languageCode"
}
],
"outputs": [
{
"name": "text",
"targetName": "translatedText"
}
]
}
I use the exact same implementation for the Named Entity Recognition Skill (using document/pages/* as input), and it works fine. I'm not sure what the difference would be with the Text Translator skill.

copyIndex() inside a listKeys()

We're trying to deploy an ARM template which deploys a Stream Analytics job with n Event Hubs outputs depending on an input parameter.
Right now we're having success with all but the listKeys() function inside the outputs property copy loop function which gets each Event Hub's primary keys:
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[copyIndex('outputs')].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]"
We get the error:
17:44:31 - Error: Code=InvalidTemplate; Message=Deployment template
validation failed: 'The template resource
'tailor-router-axgf7t3gtspue' at line '129' and column '10' is not
valid: The template function 'copyIndex' is not expected at this
location. The function can only be used in a resource with copy
specified. Please see https://aka.ms/arm-copy for usage details..
Please see https://aka.ms/arm-template-expressions for usage
details.'.
However, if we change this to be a specific index:
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[0].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]"
it works.
Is copyIndex('propertyName') inside a listKeys() a supported function?
If not, is there a workaround that would achieve the same effect?
Kind regards,
Nick
Stream Analytics job resource definition:
{
"apiVersion": "2016-03-01",
"type": "Microsoft.StreamAnalytics/StreamingJobs",
"name": "[variables('routerStreamAnalyticsName')]",
"location": "[variables('location')]",
"dependsOn": [ "clientsEventHubCopy" ],
"tags": {
"boundedContext": "[variables('boundedContextName')]"
},
"properties": {
"sku": {
"name": "[parameters('routerStreamAnalyticsSkuTier')]"
},
"outputErrorPolicy": "drop",
"eventsOutOfOrderPolicy": "adjust",
"eventsOutOfOrderMaxDelayInSeconds": 0,
"eventsLateArrivalMaxDelayInSeconds": 5,
"dataLocale": "en-US",
"compatibilityLevel": "1.0",
"inputs": [
{
"name": "input0",
"properties": {
"type": "stream",
"serialization": {
"type": "Avro"
},
"datasource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"serviceBusNamespace": "[parameters('input0EventHubNamespace')]",
"sharedAccessPolicyName": "[parameters('input0EventHubSharedAccessPolicyName')]",
"sharedAccessPolicyKey": "[parameters('input0EventHubSharedAccessPolicyKey')]",
"eventHubName": "[parameters('input0EventHubName')]"
}
}
}
}
],
"transformation": {
"name": "routing",
"properties": {
"streamingUnits": "[parameters('routerStreamAnalyticsSkuTier')]",
"query": "omitted"
}
},
"copy": [
{
"name": "outputs",
"count": "[length(parameters('clients'))]",
"input": {
"name": "[parameters('clients')[copyIndex('outputs')].id]",
"properties": {
"datasource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"serviceBusNamespace": "[variables('clientEventHubNamespace')]",
"sharedAccessPolicyName": "[variables('clientEventHubClientSharedAccessName')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[copyIndex('outputs')].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]",
"eventHubName": "[parameters('clients')[copyIndex('outputs')].id]"
}
},
"serialization": {
"type": "Avro"
}
}
}
}
]
}
},
Thanks for reporting this and sorry for the inconvenience.
I just talked to the ARM team, we had an issue when copyindex was inside the index tags eg 'array[copyindex()]'. It should be fixed now.
Let us know how it goes.
Thanks,
JS - Azure Stream Analytics

Resources