I was asked to upgrade an existing site from using the old remarketing tracking code that looked like this:
<script type="text/javascript">
var google_conversion_id = 12345;
var google_custom_params = window.google_tag_params; // this is empty
var google_remarketing_only = true;
</script>
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/12345/?value=0&guid=ON&script=0"/>
</div>
</noscript>
to another method that looks like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-12345"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'AW-12345');
</script>
because it is asynchronous and should not block page loading. But the Google Tag Assistant extension that validates that tracking is set up correctly asks me to enter a "feed ID" when using the newer (gtag.js based) method. Previously it was showing Remarketing Tag as green.
Why is it needed now and not with the old code? I asked someone who has access to the AdWords account and they don't have the feed ID (or can't find it...).
I verified that the request to googleads.g.doubleclick.net/pagead/viewthroughconversion/ is sent though devtools as described in Verifiction using browser based developer tools:
https://developers.google.com/adwords-remarketing-tag/verification
Is my configuration correct?
That feed ID is related to dynamic remarketing campaigns. If you aren't running a dynamic campaign, then the feed ID shouldn't matter.
That field to enter a feed ID is there to help you with validating that your feed is working correctly.
Here is a quick video that might help clear up your questions. https://www.youtube.com/watch?v=QuOUNIFo0aQ
Related
I am wondering, if conversion value for Google AdWords Pixel could be negative?
Does anyone have experience with negative google_conversion_value?
My idea is to send contribution margins instead of revenue.
This is the example from help pages (https://support.google.com/google-ads/answer/6331314):
<html>
<head>
<title>HTML-Beispieldatei</title>
</head>
<body>
<!-- Google-Code für Kauf-Conversion-Seite -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234567890;
var google_conversion_label = "xxx-XXx1xXXX123X1xX";
var google_remarketing_only = "false"
var google_conversion_value = 10.0;
var google_conversion_currency = "EUR"
/* ]]> */
</script>
<script type="text/javascript"
src="//www.googleadservices.com/pagead/
conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="//www.googleadservices.com/pagead/
conversion/1234567890/
?value=10.0¤cy_code=EUR&label=xxx-
XXx1xXXX123X1xX&guid=ON&script=0">
</noscript>
</body>
</html>
negative values are not accepted from the Google Ads Api
see
what you can also do if you don´t want to expose your margin on the page: set up a Server 2 Server communication with Google Ads API (or simply via Google Sheet if you just want to test and avoid programming)
so summing up:
On success page send no conversion value, only conversion pixel
upload daily your conversion values using Restate or Retract logic
I don't think GTM is recording data correctly for my Rails app. When i use the preview feature, the GTM preview data in developer tools only shows on initial page loads, subsequent page loads (using turbolinks) do not show the preview data. How should I set up GTM with TurboLinks?
I have set up my GTM in the header like this:
<script>
var dataLayer = [];
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-N7MDCP');</script>
<!-- End Google Tag Manager -->
And then at the top of the body:
<script>
<% if user_signed_in? %>
dataLayer.push({'userID': '<%= current_user.id %>'},{'userCategory': 'User'});
<% end %>
</script>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N7MDCP"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<!-- Google Tag Manager trigger for Turbolinks -->
<script type="text/javascript">
var url = window.location.href;
dataLayer.push({
'event':'pageView',
'virtualUrl': url
});
</script>
<!-- End Google Tag Manager trigger for Turbolinks -->
This has to do with how the preview mode injects the debugger iframe.
It is injected on the initial page load, but since turbolinks replaced the entire body it also removes the preview panel from -ALL- subsequent page reloads.
It is sadly pretty much how it is and not much one can do about it.
Your GTM implementation is probably still working, but preview mode in Google Tag Manager is not compatible with turbolinks page reloads.
And yes, this makes debugging GTM in turbolinks enhanced sites a major pain.
dataLayer.push(
{'userID': '<%= current_user.id %>'},
{'userCategory': 'User'}
);
instead please try
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'userID': '<%= current_user.id %>',
'userCategory': 'User'
});
This is untested.
I have noticed your use of braces '{'
I am trying to implement Google Adwords conversion tracking within the confines of a very restrictive process management tool, which strips out any <script> content I use.
As the tracking code consists of the script and an image tag, and both include ID and conversion label, I wondered if I can use the image without the script.
i.e not this:
<!-- Google Code for CONVERSION NAME -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "YYYYYYY";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
but only this image tag:
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/XXXXXXX/?label=YYYYYYY&guid=ON&script=0"/>
And this again not:
</div>
</noscript>
Will this work? I am posting this as a question here as our system leaves few options for testing (process needs to go offline in order to implement changes).
Thanks for your help!
Yes, it will work. You can use just the image tag, in fact, when you use the script part, in the end, that code appends one image to your html.
Can someone explain how should we properly integrate Googletagmanager with Turbolinks?
On normal pages we just copy/paste this code immediatelly after after the opening tag.
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-******"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); //f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-******');</script>
<!-- End Google Tag Manager -->
If I copy this code inside Turbolinks powered page I can see there is only one network request (when page loads for the first time)
I got page refreshes working following this guide
It suggests that you set up a virtual url macro and pageview rule in Tag Manager, and then push it to the dataLayer:
$(document).on('page:change', function(){
dataLayer.push({
'event':'pageview',
'virtualUrl': window.location.pathname
});
});
Implement google tag manager with turbolink 5.
copy the code below and paste inside the head.
<!-- Google Tag Manager -->
<% if Rails.env.production? %>
<script>
document.addEventListener('turbolinks:load', function(event) {
var url = event.data.url;
dataLayer.push({
'event':'pageView',
'virtualUrl': url
});
});
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','[YOUR-GTM-ID]');
</script>
<% end %>
<!-- End Google Tag Manager -->
You can bind events with Turbolinks to page:load (as opposed to $(document).ready)
$( window ).on( 'page:load', function () {
// Do something
} );
Google Tag Manager's documentation specifies:
Google Tag Manager supports dynamic pages through events.
They provide some documentation about events here: https://developers.google.com/tag-manager/devguide#events - but the specific implementation will depend on what you're doing with GTM.
The two existing answers are incomplete. Here is the full solution, along with information on how to configure GTM for your change:
Add this to your site:
<script type="text/javascript">
$(document).on('page:change', function(){
var url = window.location.href;
dataLayer.push({
'event':'pageView',
'virtualUrl': url
});
});
</script>
Once you've done that, register the trigger in Google Tag Manager and associate that trigger with the desired tags.
The complete instructions are available here: http://labs.wrprojects.com/how-to-use-google-tag-manager-with-rails-and-turbolinks/
We are displaying some ads in our iOS & Android applications using the Google Mobile Ads SDK. We need some parameters to make a web service call when the user clicks on the Ad and we get them using the GADAppEventDelegate, and after the web service call we present a custom screen. (so we don't want to redirect the user to a Web Page). The problem is that the Clicks are not tracked and we believe that Ad Creative might not be configured right.
<html><body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<html>
<head>
<script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function fireEvent() {
admob.events.dispatchAppEvent("query_string", "ad_origin_key=USPS2013_iPhone_Upgraded_320x50&k_key=&acid_key=719768856&ad_image_url_key=http://USPS2013_iphone_320x50");
}
</script>
</head>
<body>
<img src="http://pagead2.googlesyndication.com/pagead/imgad?id=CICAgIDQ59KwChABGAEyCKGNWPM-wPBl" width="320" height="50" border="0" onclick="fireEvent()"/>
</body>
</html></body></html>
I believe that in order not to be redirected to a Web Page we should make an AJAX request in fireEvent() function, something like $.get("%%CLICK_URL_UNESC%%www.example.com/ads/landingpage"); but the browser doesn't allow AJAX request to a server different of the original request server.
So how could we solve this issue, track the clicks and not navigate to a new web page?
Thanks
Hello i think this answer is a bit late but the code you quoted actually works!!
Inside your head tag of HTML of the creative
<script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
// Send an event when ad loads.
// admob.events.dispatchAppEvent("adId", "1");
// handle your click with onClick="handleClick()"
handleClick = function() {
admob.log("click ad: call handleClick()"); // call a log to XCode console for debug
// Send an event when ad is clicked.
admob.events.dispatchAppEvent("eventName", "params"); //{action}|{action params}...
//magic goes here
//i think the click measure through this url
//and use jQuery get that send get method without callbacks
$.get("%%CLICK_URL_UNESC%%")
};
</script>
You have to wait a while like 30 mins then you will see the click stats in your DFP console.