Fire Adwords remarketing list on virtual page view - google-ads-api

Hi I'm trying to fire a specific remarketing list tag with Google Tag Manager. In the debugging everything works perfectly. I'm triggering the specific list tag and the global Adwords remarketing tag and it works. Although, nothing populates in Adwords.
I've a statement in GTM which triggers the tag if the virtual page view equals an URL and it works.
I've tried to different tags for the specific lists:
<script>
gtag('event', 'conversion', {
'send_to': 'AW-XXXXXXXXX/ZZZZZZZZZZZZZZZZZ',
'value': 1.0,
'currency': 'SEK',
'aw_remarketing_only': true
});
</script>
and
<script>
gtag('event', 'conversion', {
'send_to': 'AW-XXXXXXXXX/ZZZZZZZZZZZZZZZZZ'});
</script>
The problem is that the lists in Adwords doesn't populates and I've checked that the specific url have had traffic which should indicate that the trigger would be fired.
Thanks!

Okey so we're using GTM to do this now to simply fire a tag with the information in the code above. Don't need to use custom HTML/script to do this.

Related

Show custom fileds based on other custom field value on CREATE ISSUE screen

I'm implementing a help desk in JIRA where I have two drop downs - both 'single value select' for Category and Sub-category.
For example,
I have following Categories:
Content Development
Events
Design
And each category has a list of sub-categories within them. For example, Design will have following list of options
Event Collateral
Branding
Business Cards
By default, ONLY Category dropdown should be displayed on the CREATE ISSUE screen.
When user selects one of the categories, corresponding sub-category drop-down should be displayed on the CREATE ISSUE screen AND that sub-category dropdown should be MANDATORY field.
I looked up for possible solution at the following links:
https://confluence.atlassian.com/display/JIRA052/Displaying+a+Field+Based+on+Another+Field+Selection
https://confluence.atlassian.com/display/JIRA/Displaying+a+Field+Based+on+Another+Field+Selection
https://answers.atlassian.com/questions/217176/show-hide-custom-field-depend-on-another-custom-field-value
The first two links basically suggests the same solution - that is to put a JAVASCRIPT in the description field of the custom field and the same is suggested on many other blogs on this issue. They all give this very same example.
However this is not working for me. When I put any JAVASCRIPT in the description of the custom-field, it runs immediately upon saving - on the Field Configuration screen. For example, I just put a following JAVASCRIPT in the description and I got the alert right away (on the Field Configuration screen).
<script type="text/javascript">
alert('hi');
</script>
However, I do not get any alert on the CREATE ISSUE screen. So, not sure if I am missing anything here. Please advise if I'm looking in the right direction.
The 3rd link, suggests to create a plugin from the JIRA machine. However, I do not have access to that machine, I just have admin access to JIRA.
Is there any feasible way to achieve it via default JIRA configurations/external plugins which are ready-to-use?
My JIRA version is: 6.1.4
I have used Java script in custom fields in JIRA 6.0.8,JIRA 6.2.4 and JIRA 6.4.8 as well, so I think it should definitely work in JIRA 6.1.4.
You only need to put java script in sub category custom field as below:
For example for Design ->
Replace customfield_ID1 with custom id of Category Custom field and customfield_ID2 with custom id of Sub Category Design Custom field
<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
callChangeFunction();
});
callChangeFunction();
function callChangeFunction(){
showHidField();
// dropdown custom field change function
$("#customfield_ID1").change(function() {
showHidField();
});
}
function showHidField(){
//drop down field selected value
var dropDownFieldval =$.trim($("#customfield_ID1 :selected").text());
//test field1
$("#customfield_ID2").closest('div.field-group').hide();
if(dropDownFieldval == 'Design'){
$("#customfield_ID2").closest('div.field-group').show();
}else
$("#customfield_ID2").closest('div.field-group').hide();
}
});
</script>
Above will show or hide the field, please ensure that Category and Subcategory custom fields both are on same screen (Ex: Create Screen)
Now in order to make them Mandatory, you need to write that code as validator on create transition in Project Workflow as below:
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;
LazyLoadedOption selOption = issue.getCustomFieldValue (customFieldManager.getCustomFieldObject('customfield_ID1'));
(selOption.getValue()=='Design' && cfValues[Name of design Sub Category field#'])|| selOption.getValue()=='Events';
Make sure that you have Behaviour Plugin installed to get simple script validator
Hope this helps!
Priyanka Lavania

Track URL change with Google Analytics without reloading the page

I have a button, that triggers JS and return different modals depending on random logic.
In order to maintain seamless flow, I can't reload page, but I need to track what modal is opened and what button is clicked in it.
I can change URLs by utilising JS window.location to track what is shown and clicked.
window.location.hash = 'clicked1'
which will alter my URL to this www.site.com/#clicked1 or www.site.com/#clicked2
Question is, how I can track it in Google Analytics?
Can someone guid me through this jungle so I can better understand the process. Should I use event tracking instead? Or I can track URLs without reloading the page.
Here is a great article about tracking a single page application with Google Analytics.
To track dynamically loaded content as distinct pageviews you can send a pageview hit to Google Analytics and specify the Document Path by setting the page field.
ga('send', 'pageview', '/#clicked1);
it's usually best to update the tracker object with any new page information prior to sending hits. This will ensure that all hits are associated with the correct page data.
To update the tracker object, use the set method:
ga('set', 'page', '/#clicked1);
If you want to update more than just the page field, you can pass an object of key/value pairs to the set method.
ga('set', {
page: '/#clicked2',
title: 'Clicked 2'
});
Once the tracker has been updated with the proper data for the new page, you can send a hit without overriding page related parameters. For example:
ga('send', 'pageview');
If you’re using analytics.js:
ga('set', 'page', '/your-own-path');
ga('set', 'title', 'Your custom title');
ga('send', 'pageview');
If you’re using gtag.js:
gtag('config', 'UA-0000000-1', {
'page_title' : 'Your custom title',
'page_path': '/your-own-path'
});
If you’re using GTM, you can use whatever dataLayer keys you wish; here’s an example:
dataLayer.push({
event: 'pageview',
page: {
path: '/your-own-path',
title: 'Your custom title'
}
});
A great article explaining those different techniques (examples quoted directly from it) : https://www.bounteous.com/insights/2018/03/30/single-page-applications-google-analytics/

jQuery mobile issues with offline web app

I'm developing an application using jQuery mobile, that will be using HTML5 offline capabilities (cache manifest, etc).
Basic program is for on-field technicians to view/modify their orders on a tablet with no internet connection. I'm using a local browser database to store the orders.
I have an orders.html page which can view any order - but to pass a parameter to it, I can't use GET parameters, because the program is offline and I can't list every single order in the manifest.
So I have to use hash parameters - eg orders.html#o4572. But jQuery mobile doesn't play nice with this scheme - it uses hash parameters for it's own schemes. When I'm on list.html and there's a link to orders.html#o4572 - it turns the link into list.html#o4752 and stays on the same page.
I can turn off jQuery mobile's link handling by setting $.mobile.linkBindingEnabled = false; but this prevents all ajax navigation - you lose the nice transitions, and pop-up dialogs don't 'just work' anymore, you have to do them manually. And there may be other issues.
Is this the only way of getting this to work properly? I'm just starting to use jQuery mobile, so I feel like I'm missing something.
I have done something similar using the jquery-mobile-router plugin with a single page app that has a offline mode, however it should work the same for a multipage app since with a multi-page app the default behavior (ajax-enabled set to true) of JQM is that it pulls in the second page and attaches it to the DOM of the current page.
Using the JQM router you should be able to do something like this
var router;
var orderHandlerRoute = function (eventType, matchObj, ui, page, evt) {
var params = router.getParams(matchObj[1]);
//use your params to pull data from localStorage
};
router = new $.mobile.Router({
'orders.html(?:[?/](.*))?' : {handler: "orderHandler", events: 'bs'}
, {orderHandler: orderHandlerRoute }
});
You should indeed not use hash parameters for anything else than selecting pages when using jquery mobile.
The standard way to proceed is to pass your parameter with file.html?parameter=value and to retrieve the value through javascript.
You can then process this value with a js function that can for instance retrieve the data with an ajax call if you are online, or read it from local storage if you are offline.
This can be done either by binding the changepage event if you want to generate your pages dynamically based on the data associated to the parameter, or by binding the pageinit event if you want to alter the page after it has been displayed (for instance fill in form elements)
Alternatively, if the use of the cache manifest prevents you from usingthe ?parameter=value syntax, you can use the following approach:
- write your target link as file.html#pagename_itemvalue
- bind the pagechange event in order to override the default behaviour, and instead parse the target value, retrieve pagename and itemvalue, and generate/access the content you want to display. You can see an example of that on this page

jQuery Mobile Page refresh mechanism

I'm having a lot of pain understanding how jQuery Mobile handles pages refresh after an ajax update.
I'm having a two pages - unique file site: a search engine.
First page is a search field. Submit triggers a JSON call and parser which updates the second page: results.
for now i'm using: $.mobile.changePage( $('#result') ); which does the job great from search field to result page.
However:
If I reuse it from result page for next/prev pages ( new json call, new parse, new added nodes in the DOM );
Jquery Mobile just don't "paint" the newly added nodes.
can anyone explain, please the use and distinction of
1- $.mobile.page()
2- $.mobile.changePage()
3- $.mobile.refresh()
or give me a hint on how I should handle page changes.
thanks!
function refreshPage()
{
jQuery.mobile.changePage(window.location.href, {
allowSamePageTransition: true,
transition: 'none',
reloadPage: true
});
}
Taken from here http://scottwb.com/blog/2012/06/29/reload-the-same-page-without-blinking-on-jquery-mobile/ also tested on jQuery Mobile 1.2.0
Please take a good look here: http://jquerymobile.com/test/docs/api/methods.html
$.mobile.changePage() is to change from one page to another, and the parameter can be a url or a page object. ( only #result will also work )
$.mobile.page() isn't recommended anymore, please use .trigger( "create"), see also: JQuery Mobile .page() function causes infinite loop?
Important:
Create vs. refresh: An important distinction
Note that there is an important difference between the create event and refresh method that some widgets have. The create event is suited for enhancing raw markup that contains one or more widgets. The refresh method that some widgets have should be used on existing (already enhanced) widgets that have been manipulated programmatically and need the UI be updated to match.
For example, if you had a page where you dynamically appended a new unordered list with data-role=listview attribute after page creation, triggering create on a parent element of that list would transform it into a listview styled widget. If more list items were then programmatically added, calling the listview’s refresh method would update just those new list items to the enhanced state and leave the existing list items untouched.
$.mobile.refresh() doesn't exist i guess
So what are you using for your results? A listview? Then you can update it by doing:
$('ul').listview('refresh');
Example:
http://operationmobile.com/dont-forget-to-call-refresh-when-adding-items-to-your-jquery-mobile-list/
Otherwise you can do:
$('#result').live("pageinit", function(){ // or pageshow
// your dom manipulations here
});
I posted that in jQuery forums (I hope it can help):
Diving into the jQM code i've found this solution. I hope it can help other people:
To refresh a dynamically modified page:
function refreshPage(page){
// Page refresh
page.trigger('pagecreate');
page.listview('refresh');
}
It works even if you create new headers, navbars or footers. I've tested it with jQM 1.0.1.
I found this thread looking to create an ajax page refresh button with jQuery Mobile.
#sgissinger had the closest answer to what I was looking for, but it was outdated.
I updated for jQuery Mobile 1.4
function refreshPage() {
jQuery.mobile.pageContainer.pagecontainer('change', window.location.href, {
allowSamePageTransition: true,
transition: 'none',
reloadPage: true
// 'reload' parameter not working yet: //github.com/jquery/jquery-mobile/issues/7406
});
}
// Run it with .on
$(document).on( "click", '#refresh', function() {
refreshPage();
});
I solved this problem by using the the data-cache="false" attribute in the page div on the pages I wanted refreshed.
<div data-role="page" data-cache="false">
/*content goes here*/
</div>
In my case it was my shopping cart. If a customer added an item to their cart and then continued shopping and then added another item to their cart the cart page would not show the new item. Unless they refreshed the page. Setting data-cache to false instructs JQM not to cache that page as far as I understand.
Hope this helps others in the future.
This answer did the trick for me http://view.jquerymobile.com/master/demos/faq/injected-content-is-not-enhanced.php.
In the context of a multi-pages template, I modify the content of a <div id="foo">...</div> in a Javascript 'pagebeforeshow' handler and trigger a refresh at the end of the script:
$(document).bind("pagebeforeshow", function(event,pdata) {
var parsedUrl = $.mobile.path.parseUrl( location.href );
switch ( parsedUrl.hash ) {
case "#p_02":
... some modifications of the content of the <div> here ...
$("#foo").trigger("create");
break;
}
});

What is a good way of tracking link clicks in Asp.Net Mvc app?

I have an MVC app with several <a> tags, and I want to have a way of tracking link clicks, preferably without doing redirects (i.e., without changing link addresses). Is there any way this can be done? And, if not, is there any way one can get this functionality automatically (e.g., with javascript)?
Thanks.
UPDATE
Taking your other wishes in consideration, this should be your way to go:
<script type="text/javascript">
$(document).ready(function() { //On document ready
$('a').click(function(e) { //For each a (anchor), set the following function
urchinTracker (this.href);
pageTracker._trackPageview (this.href);
//Custom tracker here?
return true; //To keep following href definitions
});
});
</script>
Consider Woopra
Since you are already using Google Analytics, they have a javascript function to put in the onclick event.
The method name is either urchinTracker or pageTracker._trackPageview depending on whether you are using urchin.js or ga.js as your Analytics script include.
An example (from here) in both formats:
<a href="/files/map.pdf" onClick="javascript:urchinTracker ('/downloads/map');">
<a href="/files/map.pdf" onClick="javascript:pageTracker._trackPageview ('/downloads/map');">
Basically what that does is call the javascript method (which does the 'analytics call' to Google's server) then does the <a> action as normal (ie. whatever the link was supposed to do - in this case open PDF files).
Is that what you are looking for - or is the jQuery answer what you wanted?
EDIT: in response to your question, this post contains a non-jQuery javascript include (here) that looks for 'downloadable files' and adds tracking. If you want to use jQuery, check out the other answer by ropstah since he/she has updated their answer to be Google Analytics-specific.
Consider using Google Analytics: you can't do any better.

Resources