GA Custom Dimension Error: ga("gtm1.set", "dimension1", undefined) - google-analytics

This is the code implemented by my developer for defining Custom Dimension. I have created new variables in GTM and added custom dimension to Universal Analytics tag.
In datalayer the variable values are showing correctly but in Pageview tag, it shows as Undefined. How to resolve this?
<script>
var dataLayer = window.dataLayer || [];
var categoryName = 'GST News and Announcements';
var parentCategory = 'gst';
var trackParams = {};
if (parentCategory) {
trackParams['blogCategory'] = parentCategory;
trackParams['blogSubcategory'] = categoryName;
} else {
trackParams['blogCategory'] = categoryName;
}
dataLayer.push(trackParams);
</script>

Related

How to set event listeners to Google Forms in script

I created a form using Google Forms UI. Now I want to enable some Form Elements based on the data from a Textfield.
function myFunction() {
var form = FormApp.openById(myformID);
var formitems = form.getItems()
//display the form elements and ids
for (var i in formitems) {
Logger.log(formitems[i].getTitle() + ': ' + formitems[i].getId());
}
var section3= form.getItemById(myformelementid)
Logger.log(section3.getTitle())
**//I want to add an eventlistener that triggers upon entering text in the textfield, the eventchange function can handle the enabling of other form elements
section3.addEventListener("change",onChangeEvent())**
}
Any help would be appreciated.
To do this in App Script (https://script.google.com/), you have to setUptrigger as follows:
function setUpTrigger() {
const form = FormApp.openById(formId);
const trigger = ScriptApp.newTrigger("onSubmit")
.forForm(form)
.onFormSubmit()
.create();
}
Then you can define the onSubmit function as follows:
async function onSubmit(e) {
const eResponse = e.response;
//get all response as an object
const response = eResponse.getItemResponses();
const responseObj = {};
//get all response as object with key value pair
for (let i = 0; i < response.length; i++) {
responseObj[response[i].getItem().getTitle()] = response[i].getResponse();
}
const email = eResponse.getRespondentEmail(); //get email address if you're collecting it
if (email) {
responseObj.email = email;
}
console.log("responseObj", responseObj);
}

Bad Value error with my Google Apps Script to Firebase

function tree1(){
var secret =SpreadsheetApp.openById('My Database Secret') ;
var sheet = secret.getSheets()[0];
var data = sheet.getDataRange().getValues();
var dataToImport = {};
for(var i = 1; i < data.length; i++) {
var admin = data[i][0];
var email = data[i][1];
var name = data[i][2];
var subject = data[i][3];
var year = data[i][4];
var testone = data[i][5];
var testtwo = data[i][6];
var testthree = data[i][7];
var average = data[i][8];
var progress = data[i][9];
dataToImport[email] = {
name:name,
emailAddress:email,
adminNo:admin,
Subject:subject,
Year:year,
testOne:testone,
testTwo:testtwo,
testThree:testthree,
Average:average,
Progress:progress
};
}
var firebaseUrl = "My Database URL";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
base.setData("", dataToImport);
}
I am attempting to use a Google Sheet App script to sync basic data for my users, using their email address as a reference.
So that when a user logs in with their email they can access test scores that the admin has.
The Database structure I would like is fairly simple that the three scores and other details are a child of the email, as you can see above.
However every time I attempt to complete the script I receive a Bad Value error.
Any ideas as to how I can remedy this problem.
Thank you in advance.

How to dynamically populate email variable in tracking-script for Contactform7 submit

On my site we are using ActiveCampaign site tracking.We are using below script in our site for tracking.I want to get the email of the customers who submitted the contact form 7. How i dynamically populate email variable from contactform7.
<script type="text/javascript">
var trackcmp_email = '';
var trackcmp = document.createElement("script");
trackcmp.async = true;
trackcmp.type = 'text/javascript';
trackcmp.src = '//trackcmp.net/visit?actid=609779006&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
var trackcmp_s = document.getElementsByTagName("script");
if (trackcmp_s.length) {
trackcmp_s[0].parentNode.appendChild(trackcmp);
} else {
var trackcmp_h = document.getElementsByTagName("head");
trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
}
</script>

Adwords Conversion OnClick

How can I make Adwords conversion OnClick without improt from analytics?
I mean, when visitor come to my landing page nothing happens, only when visitor click on specific link it will counted as new conversion.
You can generate code from AdWords in advanced section. Then code should looks like this:
<!-- Google Code for XXXXXX Conversion Page
In your html page, add the snippet and call
goog_report_conversion when someone clicks on the
chosen link or button. -->
<script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = XXXXXX;
w.google_conversion_label = "XXXXXXXX";
w.google_remarketing_only = false;
}
// DO NOT CHANGE THE CODE BELOW.
goog_report_conversion = function(url) {
goog_snippet_vars();
window.google_conversion_format = "3";
window.google_is_call = true;
var opt = new Object();
opt.onload_callback = function() {
if (typeof(url) != 'undefined') {
window.location = url;
}
}
var conv_handler = window['google_trackConversion'];
if (typeof(conv_handler) == 'function') {
conv_handler(opt);
}
}
/* ]]> */
</script>
<script type="text/javascript"
src="//www.googleadservices.com/pagead/conversion_async.js">
</script>
All the hints you can find in Adwords and Google support.
this will help https://support.google.com/adwords/answer/6095821?hl=en they have a video guide

IE8 post file targeting iframe, arrives on server as null

I have a form with just an input:file in it and the form targets a named iframe. when the user selects a file it automatically posts the form to the server. This works in IE10/firefox/chrome, but in IE8 the File parameter on my controller method is null when IE8 posts the form. Has anyone else encountered this and know of any solutions, why isn't IE8 actually posting the file data?
ClientSide:
function createFileUploadForm()
{
var frameName = 'fileUploadFormFrame';
var fileValue;
var fileUploadCallback = function()
{
//do stuff when the server responds after receiving the file
};
var fileInputChangedCallback = function(event)
{
if(fileInput.value != fileValue)
{
fileValue = fileInput.value;
form.submit();
}
};
var iFrame = document.createElement('iframe');
iFrame.name = frameName
document.body.appendChild(iFrame);
var form = document.createElement('form');
form.action = 'a/valid/url';
form.method = 'post';
form.enctype = 'multipart/form-data';
form.target = frameName;
var fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.name = 'File';
fileInput.accept = '.spc';
fileValue = fileInput.value;
//all browsers except IE8
//add event listener to fileInput onChange event -> fileInputChangedCallback
//IE8 fix
//add event listener to fileInput onFocus event -> fileInputChangedCallback
form.appendChild(fileInput);
document.body.appendChild(form);
}
ServerSide:
[HttpPost]
public ActionResult UploadFile(HttpPostedFileBase File)
{
//do stuff with File, but in IE8 File parameter is null
}
the problem was that IE8 requires an additional encoding property on the form to be set:
var form = document.createElement('form');
form.action = 'a/valid/url';
form.method = 'post';
form.enctype = 'multipart/form-data';
form.encoding = 'multipart/form-data'; //this additional line fixes the IE8 problem I was having
form.target = frameName;

Resources